Design and implement a four arithmetic operation interpreter with C #

Source: Internet
Author: User
Tags arithmetic data structures

This afternoon a simple four arithmetic interpreter (interpreter) was written in C #. The interpreter has two main functions: one is to be able to carry out basic arithmetic, namely subtraction; the second is to be able to detect input syntax errors, for illegal operation instructions will prompt errors and give the wrong place. In the evening I wrote this blog post to record the thought process.

Press: This is the previous encounter of a Microsoft technical interview questions, then feel more trouble, to involve the use of tree trees and other data structures, so has been kept in mind. I happened to get the legendary Dragon book this afternoon, so I tried to write it by myself.

The interpreter, which took 2 hours to write, is relatively simple and can only be arithmetic. Parentheses are not yet supported, as well as unary operators, such as the minus sign operator. Source code can be downloaded here: http://files.cnblogs.com/yinyueyouge/Arithemic.7z

The main interface for running is as follows:

The interpreter can also judge illegal input:

Now the interpreter is very primitive. If a bug is found, please indicate it and I will correct it. :)

Related Article

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.