-
The so-called suffix expression is to write a @ b as a b @其中前者是我们日常生活中的中缀表达式, followed by a suffix expression.
For example, 7*8 becomes 7 8*
For example, 6-9 becomes 6 9-
For example, 5*(3+2), the suffix expression is 5 3 2 + to know that the suffix expression has no parentheses.
Then scan the symbols in turn, the numbers will go directly into the stack, and when the operator is encountered, the first two numbers will be out of the stack, and the result will be put into the stack after the operation:
For example, 5, 3, 2+
Scan 5 – > 5
Scan 3 – > 5 3
Scan 2 – > 5 3 2
Scan 5 – > 5
Scan*-25
So the problem you have to solve now is how to convert an infix expression into a suffix expression.
Again, this is done through the stack.
Scan from left to right, encounter digital direct outputs, encounter symbolic comparison of priority stacks or outputs (high priority stacks, small or equal direct outputs. The precedence of the opening parenthesis is greater than multiplication and division is greater than addition and subtraction), the left parenthesis will enter the stack, the right parenthesis will output all the symbols in the left parenthesis in the stack, and all the symbols in the stack will be output at the end.
For example, 5, 3, 2+
Scan 5 direct output.
Scan for * into the stack (in-stack: *).
Scan ( Stack (on-site:*.)
Scan 3 Direct output.
The priority of scan++ is less than the priority of (, into the stack, (in-stack: *scan2 direct output.
Scan) scans all the output in the station (before, i.e., the output was + scanned to the end, and all the things in the stack are output, i.e., the output is *summed up, and the output is 5 3 2 +
You can see this link.
It's mine too.
-
Hello!! Is this the effect, satisfied, add more points, and send you a private message.
-
Arithmetic There are a total of 34 operators in the C language, including common addition, subtraction, multiplication, and division operations.
Additive operation + subtraction operation -
Multiplication * Division
The remainder operation % is self-increasing and self-decreasing Simple to use.
5++ is wrong.
Difference Between A and A++.
sizeof
Role: Basic form.
Logical Operations 1&&&Logic with.
1> Use formatting.
2> Results.
3> Operation.
4> Examples.
5> Note.
Logic or. 1> Use formatting.
2> Results.
3> Operation.
4> Examples.
5> Note.
Logical non. 1> Use formatting.
2> Results.
3> Examples.
4> Note.
Trinocular operator.
n-mesh operator - > trinocular operator.
The program calculates the angle between the two needles at any time between 0:00 and 23:59. >>>More
#include
int main() >>>More
Question 1: pt1=&a;pt2=&b;pt1 and pt2 are not defined, years are defined as. >>>More
In the C language. An integer constant starting with 0 refers to octal. 027 is 2x8+7, so the answer is c.
char *p;
uchar log_type; >>>More