1.求算术表达式的值
others' mentality
first, find out the suffix expression.
put the string in an array and named as exp, and define another array named postexp, which is to put the suffix expression. The two arraies are typed of char. In order to make the trance come true, a operation stack is necessary. A stack is named as op to stor the operations in the original expression. To follow the rule of caculation, we need to define the primary of the opertaions as the following table. ps.the lpri means the char from the exp in the process of traversal. the rpri is the char in the op.
Second, do operation with the postexp.
A number stack is necessary, which is to put the result of each stp of operation.
Traversal op and when meet numbers get out and get it stored in the stack and when meet an operation, get out two numbers from the number stack and do the operation with the numbers that you get out from the stack and put the result back to the stack untile the postexp is traversaled over.
Code written with the help of book
5.Summary
stray \241 or \243 in program means that there are Chinese input
When I get a problem, I should be clam down and try to find the solution with the knowledge that I have learnt, just to try it.