Manual transformation of infix and prefix and suffix

Source: Internet
Author: User

The reason for manual deduction is, of course, for the exam. Amount.

For programming implementation, please search by yourself. I did not find any of the following content, so I wrote it down. One was a memo, and the other helped to save some time for the children's shoes preparing for the exam.

Few gossip, and listen to the text:

[1]Evaluate:

1.1 infix evaluation:(Needless to say, You know)

Before 1.2, suffix type evaluation:The program requires a stack, of course, but the "stack" is a computer thinking model. We humans need to maintain a stack in our minds. The IQ requirement is relatively high, in my own low IQ, it is quite difficult. Therefore, the curve saves the nation: Convert the prefix and suffix into the infix type, and the infix value is referred to the above one.

[2]Conversion

Because it is not very convenient to simulate stack operations through mental computing or drawing, the following methods are summarized.

1.1 suffix (prefix) to infix

For example, if you want to convert the suffix AB * CDE/-f * + into an infix

        

Search for the operator from left to right. If you find the operator, combine the symbol with the first two numbers and use a loop.

1.2 infix to suffix (prefix)

For example, convert the infix A * (B * (C + D/E)-f) to a suffix.

      

      

Add brackets to all operation units according to the operator priority. Then, move the symbols in the brackets to the corresponding brackets and remove the brackets. BTW, this painting method has never been used by others and belongs to the original category. It is accidental if it is similar. In addition, if you only have a black pencil, consider parentheses and square brackets.

At this point, the points for such questions in the soft exam should be able to be scored.

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.