C Analog Calculator Program 10

Updated on technology 2024-02-09
3 answers
  1. Anonymous users2024-02-05

    Wrote about this the other day, 6-1Simple calculator (20).

    Time Limit. 400 ms

    Memory limits. 32000 kb

    **Length limit.

    8000 b

    Judgment procedure. standard

    Author: Tongyu Zhang (Zhejiang University).

    Simulate the work of a simple combinator. Suppose the calculator can only perform addition, subtraction, multiplication and division, the operation number and the result are integers, and the 4 operators have the same priority, calculated in order from left to right.

    Input format: The input gives a four-rule operation equation in a line, with no spaces, and at least one operand. If the equal sign "=" is encountered, the input is over.

    Output format: Output the result of the equation in one line, or if the division denominator is 0 or there is an illegal operator, the error message "error" will be output. Input sample:

    Sample output: include

    #include

    int main()

    sum/=i;

    elsescanf("%c",&j);

    printf("%d",sum);

    end:return 0;}

  2. Anonymous users2024-02-04

    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.

  3. Anonymous users2024-02-03

    Hello!! Is this the effect, satisfied, add more points, and send you a private message.

Related questions
34 answers2024-02-09

PS2 emulator does not support the following graphics cards, such as x800, r9800, etc., directx is the patch of the graphics card driver, copy all the contents of the compressed package to c: windows system32! >>>More

7 answers2024-02-09

How do you know the due date of ovulation?

As for the question of how to calculate the due date of ovulation, in fact, if we regard the day of ovulation as the day of fertilization, then from the day of ovulation, about 38 weeks, that is, about 266 days is the due date of the expectant mother. Of course, the due date is only an approximate estimate, and it does not mean that the expectant mother will enter labor on the due date. >>>More