Title:
suan_shu_biao_da_shi_qiu_zhi Download
Description: 1, the expression is usually composed of operand, operator and delimiter. Operands can have constants, variables, or identifiers. Operators are divided into arithmetic operators, relational operators, and logical operators. The basic limiter has the left and right parenthesis and the end of the expression. In order to simplify the procedure, we can only discuss the value of simple arithmetic expressions. This expression only contains addition, subtraction, multiplication, division, and four operator, parentheses, and terminator '#'.
2. Basic idea of algorithm:
Building two stacks: one is the operation number stack (Stack_nd), which is used to store operation number or operation result; The other is the operator stack (Stack_tr), which is used to store operators and bounds.
& # 61548 in turn read the expression of characters, and if the operand is pressed into the operand stack (Stack_nd), if the operator, and computing stack elements (Stack_tr) stack is priority, according to the result of comparison of the corresponding operation.
3. Specify the priority between operators; The operator q1 and q2 are one of the following three relationships:
The & # 61548 q1 & lt; Q2 q1 is less than q2
The priority of q1=q2 q1 is q2
The & # 61548 q1 & gt; The priority for q2 q1 is higher than q2
To Search:
File list (Check if you may need any files):