[问题] 中置式变后置式

楼主: 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