SBE201A6 - Tertiary Calculator

In this problem, you will implement a simple arithmetic expression parser.

Given lines of two arithmetic operations (one of addition, subtraction, multiplication, or division), you will output lines that constitute the mathematical evaluation of the corresponding input lines, taking operator precedence into account.

Intermediate calculations should be done in double precision.

Input

Each input line is in the format:

    num1 [op1] num2 [op2] num3

All numbers are single-precision floating point numbers.

Operators can be one of '+', '-', '*', and '/'

Output

For each input line, you will output the result of evaluating the input arithmetic expression, taking operator precedence into consideration ('*' and '/' have higher precedence than '+' and '-').

Example

Input:
56.1814 * -896.744 / -1.90273e+06
-75.3324 - 14.335 / 170943
81.6215 / 154.868 - -3.05828e+06

Output:
0.0264779
-75.3325
3.05828e+06

HINT: use atof() to convert input numbers into single-precision floating point numbers, and use printf("%g") to output the calculated double precision results. Continue reading input lines until no more input characters are available.


Added by:Islam Samir Badreldin
Date:2012-04-09
Time limit:5s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:C99

© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.