An infix-to-Other equation conversion method ~ ~

Source: Internet
Author: User

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

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

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

The way people think is easy to fix ~~! Just as used to pull 10 into the system. Yes, 2,3,4,8,16.
Wait for the system to be overwhelmed like ~~!

The way people are used to arithmetic is infix expression. And hit the prefix, suffix way: Confused
It's just a way of expressing a formula (not the way you get used to it)
I'm here to teach you a way that maybe your teacher didn't tell you. Simple conversion

An infix-to-Other equation conversion method ~ ~
Here I give an infix expression ~
a+b*c-(D+e)
The first step is to add parentheses to all units of operation by the precedence of the operator ~
The formula becomes Pull: ((A + (B*C))-(d+e))
Step two: Convert prefix and suffix expressions
Prefix: Move the operation symbol before the corresponding parenthesis
It becomes pull:-(+ (A * (BC)) + (DE))
Remove the brackets:-+a*bc+de prefixes appear
Suffix: Move the operation symbol after the corresponding parenthesis
It becomes a pull: ((A (BC) *)-(DE) +)-
Remove the brackets: the abc*-de+-suffix appears
Found no, prefix, suffix is not required to use parentheses to determine the priority.

If you're used to pulling his algorithm. It is calculated from the front of both operands
or find the operator later. Instead of looking in the middle, then you can just mental arithmetic pull.

turn from: http://blog.csdn.net/glldc/article/details/1818787

One infix to other formulas ~ ~

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.