EvaluateReversePolishNotation

所属分类:matlab编程
开发工具:C/C++
文件大小:1KB
下载次数:2
上传日期:2015-03-15 23:06:09
上 传 者www2620552
说明:  Evaluate the value of an arithmetic expression in Reverse Polish Notation. Valid operators are +, -, *, /. Each operand may be an integer or another expression. Some examples: [ 2 , 1 , + , 3 , * ] -> ((2 + 1) * 3) -> 9 [ 4 , 13 , 5 , / , + ] -> (4 + (13 / 5)) -> 6 分析:这一题就是写程序计算逆波兰式的结果,遍历表达式,碰到操作数入栈,碰到操作符就从栈顶取出两个操作数,再将计算后的结果入栈,最后栈中剩余的唯一操作数就是计算结果。
(. Evaluate the value of an arithmetic expression in Reverse Polish Notation Valid operators are+,-,*,/Each operand may be an integer or another expression Some examples:.. [" 2" , " 1" , " +" , " 3 " ," * " ]-> ((2+ 1)* 3)-> 9 [" 4 " ," 13 " ," 5 " ," /" ," + " ]-> (4+ (13/After this problem is to write a program to calculate the inverse Polish results, iterate expression operand stack encounter, encounter operator to fetch two operands the stack, and then calculated as follows:> 6 Analysis- 5)) The results of the stack, the only remaining operand stack is the final calculations.)

文件列表:
EvaluateReversePolishNotation.cpp (937, 2015-03-15)

近期下载者

相关文件


收藏者