數(shù)據(jù)結構(9.13)

1.求算術表達式的值

others' mentality

first, find out the suffix expression.

put the string in an array and named as exp, and define another array named postexp, which is to put the suffix expression. The two arraies are typed of char. ?In order to make the trance come true, a operation stack?is necessary.?A stack is named as?op to stor the operations in the original expression.?To follow the rule of caculation, we need to define the primary of the opertaions as the following?table.?ps.the lpri means the char from the exp in the process of traversal. the rpri is the char in the op.

if the leftpri's primary is higher than the right one, which means that the operation should be poped from the op and putted into the postexp; else if the leftpri's primaty is lower than the right one, which means that the operation?was put into?op and the traversal?goes on. else,?get out all the?left operations in the op in order and put them in?the postexp. The postexp is the?suffix expersion of the orgiainal expression.

Second, do operation with the postexp.

A number stack is necessary, which is to put the result of each stp of operation.

Traversal op and when meet numbers get out and get it stored in?the stack?and when meet an operation, get out two numbers from the number stack and do the operation with the numbers that you get out from the stack and put the result back to the stack untile the postexp is traversaled over.

Code written?with the help of?book


5.Summary

stray \241??or ?\243?in program means that there are Chinese input

When I get a problem, I should be clam down and try to find the solution with the knowledge that I have learnt, just to try it.

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個濱河市猬腰,隨后出現(xiàn)的幾起案子渤涌,更是在濱河造成了極大的恐慌翘紊,老刑警劉巖,帶你破解...
    沈念sama閱讀 221,695評論 6 515
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件皮假,死亡現(xiàn)場離奇詭異怔接,居然都是意外死亡锐涯,警方通過查閱死者的電腦和手機犬辰,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 94,569評論 3 399
  • 文/潘曉璐 我一進店門嗦篱,熙熙樓的掌柜王于貴愁眉苦臉地迎上來蓄愁,“玉大人溅漾,你說我怎么就攤上這事酌伊∨古睿” “怎么了琳状?”我有些...
    開封第一講書人閱讀 168,130評論 0 360
  • 文/不壞的土叔 我叫張陵侮措,是天一觀的道長肚吏。 經常有香客問我涎劈,道長轿偎,這世上最難降的妖魔是什么典鸡? 我笑而不...
    開封第一講書人閱讀 59,648評論 1 297
  • 正文 為了忘掉前任,我火速辦了婚禮坏晦,結果婚禮上萝玷,老公的妹妹穿的比我還像新娘。我一直安慰自己昆婿,他們只是感情好球碉,可當我...
    茶點故事閱讀 68,655評論 6 397
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著仓蛆,像睡著了一般睁冬。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上看疙,一...
    開封第一講書人閱讀 52,268評論 1 309
  • 那天豆拨,我揣著相機與錄音,去河邊找鬼能庆。 笑死辽装,一個胖子當著我的面吹牛,可吹牛的內容都是我干的相味。 我是一名探鬼主播拾积,決...
    沈念sama閱讀 40,835評論 3 421
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼丰涉!你這毒婦竟也來了拓巧?” 一聲冷哼從身側響起,我...
    開封第一講書人閱讀 39,740評論 0 276
  • 序言:老撾萬榮一對情侶失蹤一死,失蹤者是張志新(化名)和其女友劉穎肛度,沒想到半個月后,有當?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體投慈,經...
    沈念sama閱讀 46,286評論 1 318
  • 正文 獨居荒郊野嶺守林人離奇死亡承耿,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內容為張勛視角 年9月15日...
    茶點故事閱讀 38,375評論 3 340
  • 正文 我和宋清朗相戀三年冠骄,在試婚紗的時候發(fā)現(xiàn)自己被綠了。 大學時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片加袋。...
    茶點故事閱讀 40,505評論 1 352
  • 序言:一個原本活蹦亂跳的男人離奇死亡凛辣,死狀恐怖,靈堂內的尸體忽然破棺而出职烧,到底是詐尸還是另有隱情扁誓,我是刑警寧澤,帶...
    沈念sama閱讀 36,185評論 5 350
  • 正文 年R本政府宣布蚀之,位于F島的核電站蝗敢,受9級特大地震影響,放射性物質發(fā)生泄漏足删。R本人自食惡果不足惜寿谴,卻給世界環(huán)境...
    茶點故事閱讀 41,873評論 3 333
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望失受。 院中可真熱鬧拭卿,春花似錦、人聲如沸贱纠。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,357評論 0 24
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽谆焊。三九已至惠桃,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間辖试,已是汗流浹背辜王。 一陣腳步聲響...
    開封第一講書人閱讀 33,466評論 1 272
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留罐孝,地道東北人呐馆。 一個月前我還...
    沈念sama閱讀 48,921評論 3 376
  • 正文 我出身青樓,卻偏偏與公主長得像莲兢,于是被迫代替她去往敵國和親汹来。 傳聞我的和親對象是個殘疾皇子,可洞房花燭夜當晚...
    茶點故事閱讀 45,515評論 2 359

推薦閱讀更多精彩內容

  • **2014真題Directions:Read the following text. Choose the be...
    又是夜半驚坐起閱讀 9,572評論 0 23
  • 她在傍晚的冷風裡等105路公交車。路上行人稀少谒兄,她裹緊了衣服在風中打了個冷戰(zhàn)摔桦。已是三月末的天氣,不該這樣冷承疲。她無聊...
    連生閱讀 258評論 0 0
  • 離家的公交車上邻耕,不斷搖曳鸥咖,抖抖停停,搖出了一些記憶片段兄世,那些消逝的啼辣,即將消失的斑駁的舊時光。望著車窗外變遷的田野碘饼,...
    辰北閱讀 290評論 0 0
  • 字符串轉data型 data轉string型 變化的我都懵逼了,有興趣的可以記一下
    寧靜1致遠閱讀 24,360評論 0 6