文件名称:EvaluateReversePolishNotation
-
所属分类:
- 标签属性:
- 上传时间:2015-03-15
-
文件大小:579byte
-
已下载:0次
-
提 供 者:
-
相关连接:无下载说明:别用迅雷下载,失败请重下,重下不扣分!
介绍说明--下载内容来自于网络,使用问题请自行百度
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.
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
本网站为编程资源及源代码搜集、介绍的搜索网站,版权归原作者所有! 粤ICP备11031372号
1999-2046 搜珍网 All Rights Reserved.