Expression prefix and suffix expression [zz]

Source: Internet
Author: User

 

35, 15, +, 80, 70,-, *, 20, // suffix expression

(35 + 15) * (80-70)/20) = 25 // infix expression

/, *, +, 35, 15,-, 80, 70, 20 // prefix expression

The way people think is easily fixed ~~! Just as we are used to pulling 10 hexadecimal. For example
Wait for the system to be overwhelmed ~~!

The calculation method that people are used to is an infix expression. Prefix and suffix .. Confused
Actually, it's just a way of expression Sub-expression (not the way you get used)
I am here to teach you a simple conversion method that your teacher may not tell you

How to convert an infix to another sub-expression ~~
Here is an infix expression ~
A + B * C-(D + E)
Step 1: Add brackets to all calculation units based on the operator's priority ~
Formula: (A + (B * C)-(D + E ))
Step 2: Convert prefix and suffix expressions
Prefix: Move the operator number to the beginning of the corresponding brackets
It turns to pull:-(+ (A * (BC) + (de ))
Remove the parentheses:-+ A * BC + de prefix
Suffix: Move the operator number to the end of the corresponding brackets
It turns to pull: (A (BC) *) + (de) + )-
Remove the brackets: ABC * + De +-suffix sub-appearance
No. prefix and suffix do not need to be determined by brackets.

If you are used to pulling his calculation method. When computing, that is, starting from the beginning of two operands
Or find the operator later. Instead of searching in the middle, you can directly calculate the result.

You may wish to convert your form into an infix .~ From my example. You should easily find the rule to pull ~

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.