[問題] 中置式變後置式

作者: november1121 (嘎樂 K.O)   2015-04-14 23:19:06
開發平台(Platform): (Ex: VC++, GCC, Linux, ...)
GCC
額外使用到的函數庫(Library Used): (Ex: OpenGL, ...)
問題(Question):
我寫了一個中置式轉後置式 但我測試了後 一直跑出亂碼 我不知道是哪裡錯了 ~
餵入的資料(Input):
(300+23)*(43-21)/(84+7)
預期的正確結果(Expected Output):
30023+4321-*847+/
錯誤結果(Wrong Output):
一堆亂碼 但我試過只打一個數字 是對的 錯應該是位於符號運算那邊
程式碼(Code):(請善用置底文網頁, 記得排版)
http://ideone.com/rw14lw
補充說明(Supplement):
作者: scwg ( )   2015-04-15 02:18:00
while(cmp(str[i],stack[top-1])==0) 忘了檢查stack是否為空
作者: kevin1ptt (蟻姨椅yee)   2015-04-16 13:26:00
cmp那段應該改成 只要stack的top優先序大於等於現在的那就可以pop

Links booklink

Contact Us: admin [ a t ] ucptt.com