Original source https://www.cnblogs.com/Hslim/p/5008460.html
Here I give an infix expression
1
|
a+b*c-(d+e)
//中缀表达
|
Step 1: Add parentheses to all operational units according to the operator's precedence
The formula becomes: ((a+(b*c))-(d+e))
Step 2: Convert the prefix and postfix Expression
prefix: Move the operator to the front of the corresponding parenthesis and
it becomes: -( +( a *(bc)) +(de)) //
Remove the parentheses when moving here: -+a*bc+de prefix expression appears
suffix: move the operator symbol after the corresponding parenthesis to
become: ((a( bc)* )+ (de)+ )
-Remove the parentheses: abc*+de+- If the suffix expression appears
, it is found that there is no, prefix type, suffix type do not need parentheses to determine the priority.
//Look at the rules yourself