[問題] 運算式 infix 轉 prefix

作者: OSDBNetwork (路人甲)   2015-12-16 04:02:29
開發平台(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 程式碼 有問題.
請問各位大大,該怎麼改程式碼呢?
感恩
作者: Qbsuran (Qbsuran)   2015-12-16 18:25:00
從後面判斷回來 ()顛倒 最後再整個反轉
作者: OSDBNetwork (路人甲)   2015-12-16 20:30:00
謝謝Q大,改好了! https://repl.it/B8j7/1// expression[0]='\0';有些是自己打錯~case '(': while(stack[top]!=')')case ')': while(InStackPriority(stack[top])...case ')': return 1;case '(':

Links booklink

Contact Us: admin [ a t ] ucptt.com