#C13761. Arithmetic Expression Evaluator
Arithmetic Expression Evaluator
Arithmetic Expression Evaluator
You are given a valid arithmetic expression in a single line. The expression consists of positive numbers (which may include decimals), the operators +, -, *, / and parentheses ( )
. Your task is to evaluate the expression and print the result.
The evaluation should follow the standard operator precedence: multiplication and division have higher precedence than addition and subtraction. Parentheses can override the natural precedence. All operations are performed left-to-right with proper grouping.
Mathematical formula for an expression E can be represented in LaTeX as:
\(E = \sum_{i=1}^{n}a_i \)
where each term ai might involve further sub-expressions enclosed in parentheses.
inputFormat
The input consists of a single line containing a valid arithmetic expression. The expression may include digits, a decimal point, the operators +, -, *, /, and parentheses. There are no extra spaces (or they can be ignored).
outputFormat
Output a single number which is the result of evaluating the given expression. If the result is a floating point number, output it using the standard formatting.## sample
3+2
5