February * 2001 ~ Every month a new interesting problem and solution by S. Filichev

Problem.

Create the interpreter of arithmetic expressions.

Example.

Input text:

2001 + 3.14 * 2 ^ 4 - 5 * ((6 + 2) / 4 + 1) ^ 2 + 6

The program prints:

2012.24

 

The note.

Do not forget about mathematical rules - the order of operators:

1. Operators in ( )

2. Calculates x to the power of y ^

3. Multiplication * and division /

4. Addition + and subtraction -

 

Solution

Basic Pascal C++
Visual Basic 6.0 Delphi 5.0 C++ Builder 5.0

 

(C) S. Filichev, 2001