[問題] 運算式 infix 轉 prefix

看板C_and_CPP作者 (路人甲)時間10年前 (2015/12/16 04:02), 編輯推噓1(107)
留言8則, 2人參與, 最新討論串1/1
開發平台(Platform): (Ex: VC++, GCC, Linux, ...) GCC 額外使用到的函數庫(Library Used): (Ex: OpenGL, ...) 問題(Question): 書本的程式 無法執行 餵入的資料(Input): 4*(5+6) 預期的正確結果(Expected Output): *4+56 錯誤結果(Wrong Output): 一堆亂碼 程式碼(Code):(請善用置底文網頁, 記得排版) https://repl.it/B8j7/0 補充說明(Supplement): 書本的 infix 轉 postfix 程式碼 正確, 但是 infix 轉 prefix 程式碼 有問題. 請問各位大大,該怎麼改程式碼呢? 感恩 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 111.255.150.163 ※ 文章網址: https://www.ptt.cc/bbs/C_and_CPP/M.1450209754.A.ACB.html

12/16 18:25, , 1F
從後面判斷回來 ()顛倒 最後再整個反轉
12/16 18:25, 1F

12/16 20:30, , 2F
謝謝Q大,改好了! https://repl.it/B8j7/1
12/16 20:30, 2F

12/16 20:30, , 3F
// expression[0]='\0';
12/16 20:30, 3F

12/16 20:31, , 4F
有些是自己打錯~
12/16 20:31, 4F

12/16 20:31, , 5F
case '(': while(stack[top]!=')')
12/16 20:31, 5F

12/16 20:33, , 6F
case ')': while(InStackPriority(stack[top])...
12/16 20:33, 6F

12/16 20:34, , 7F
case ')': return 1;
12/16 20:34, 7F

12/16 20:35, , 8F
case '(':
12/16 20:35, 8F
文章代碼(AID): #1MS77QhB (C_and_CPP)