ONP - Transform the Expression
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).
t [the number of expressions <= 100] expression [length <= 400] [other expressions]
Text grouped in [ ] does not appear in the input file.
The expressions in RPN form, one per line.
Input: 3 (a+(b*c)) ((a+b)*(z+x)) ((a+t)*((b+(a+c))^(c+d))) Output: abc*+ ab+zx+* at+bac++cd+^*
As an alternative to shunting yard, you can parse the input to abstract syntax tree, then convert it to reverse polish notation by doing a postorder traversal on the tree.
if don't know stacks you can use vector but stack makes your life easier. But while using any data structure be aware of the string and char difference and make it a point.
@lazorzor. There are multiple test cases. You need to read the number of testcases, and process each one.
PLEASE any help will be immensely appreciated. Please look at the code below.
If you are really stuck search in google "shuting yard algorithm" there are an implementation in pseudocode.
idea: Transform to postfix expression
Learnt the concept of stack through this question.
easy to solve
Browse wikipedia for RPN. You'll get an idea!
|Cluster:||Cube (Intel G860)|
|Languages:||All except: NODEJS PERL6 VB.NET|