SPOJ Problem Set (classical)4. Transform the ExpressionProblem code: ONP |
Transform the algebraic expression with brackets into RPN form (Reverse Polish Notation). Two-argument operators: +, -, *, /, ^ (priority from the lowest to the highest), brackets ( ). Operands: only letters: a,b,...,z. Assume that there is only one RPN form (no expressions like a*b*c).
Input
t [the number of expressions <= 100] expression [length <= 400] [other expressions]
Text grouped in [ ] does not appear in the input file.
Output
The expressions in RPN form, one per line.
Example
Input: 3 (a+(b*c)) ((a+b)*(z+x)) ((a+t)*((b+(a+c))^(c+d))) Output: abc*+ ab+zx+* at+bac++cd+^*
本文介绍如何将带括号的代数表达式转换为逆波兰表示法(RPN)。通过示例展示了输入输出格式,并提供了一个C语言实现方案,该方案使用栈来处理表达式。
786

被折叠的 条评论
为什么被折叠?



