#C12799. Expression Evaluation
Expression Evaluation
Expression Evaluation
You are given a string representing a mathematical expression made up of non-negative integers, parentheses, and the four basic operators: +
, -
, *
, and /
. The expression may contain spaces.
The evaluation of the expression must follow the standard operator precedence. In particular, multiplication and division have higher precedence than addition and subtraction. Formally, the precedence rules can be summarized as: $$*$$ and $$/$$ have a precedence of 2, while $$+$$ and $$-$$ have a precedence of 1.
When performing division, you should truncate the result toward zero (i.e. perform integer division).
Your task is to read a single line from the standard input containing the expression and output its evaluation as an integer to the standard output.
inputFormat
The input consists of a single line which contains the mathematical expression.
outputFormat
Output a single integer which is the result of evaluating the expression.
## sample1+1
2