#C8440. Evaluate Mathematical Expression
Evaluate Mathematical Expression
Evaluate Mathematical Expression
You are given a mathematical expression as a string which may include integers, the operators +
, -
, *
, /
and parentheses. Your task is to evaluate the expression and output the result as an integer. Note that division is integer division, i.e. it truncates towards zero. For example, \(\frac{5}{2} = 2\).
The expression should be evaluated following the standard order of operations (parentheses, multiplication and division, addition and subtraction). You can assume that the input expression is valid.
inputFormat
A single line containing the mathematical expression. The expression may contain spaces, digits, parentheses, and the operators +, -, *, and /. For instance: (3+5)*2
.
outputFormat
Print a single integer, the result of evaluating the expression.## sample
3+2
5