The reason for manual deduction is, of course, for the exam. Amount.
For programming implementation, please search by yourself. I did not find any of the following content, so I wrote it down. One was a memo, and the other helped to save some time for the children's shoes preparing for the exam.
Few gossip, and listen to the text:
[1]Evaluate:
1.1 infix evaluation:(Needless to say, You know)
Before 1.2, suffix type evaluation:The program requires a stack, of course, but the "stack" is a computer thinking model. We humans need to maintain a stack in our minds. The IQ requirement is relatively high, in my own low IQ, it is quite difficult. Therefore, the curve saves the nation: Convert the prefix and suffix into the infix type, and the infix value is referred to the above one.
[2]Conversion
Because it is not very convenient to simulate stack operations through mental computing or drawing, the following methods are summarized.
1.1 suffix (prefix) to infix
For example, if you want to convert the suffix AB * CDE/-f * + into an infix
Search for the operator from left to right. If you find the operator, combine the symbol with the first two numbers and use a loop.
1.2 infix to suffix (prefix)
For example, convert the infix A * (B * (C + D/E)-f) to a suffix.
Add brackets to all operation units according to the operator priority. Then, move the symbols in the brackets to the corresponding brackets and remove the brackets. BTW, this painting method has never been used by others and belongs to the original category. It is accidental if it is similar. In addition, if you only have a black pencil, consider parentheses and square brackets.
At this point, the points for such questions in the soft exam should be able to be scored.