#C2266. Arithmetic Expression Evaluation
Arithmetic Expression Evaluation
Arithmetic Expression Evaluation
Given a string representing an arithmetic expression that contains non-negative integers, operators + (+), - (−), * (×), / (÷), and parentheses, compute its value. The expression follows the standard operator precedence, and the division operator uses integer division (i.e. discarding any fractional part). For example, evaluate the expression in the following cases:
- \(3+2*2\) evaluates to 7
- \( 3/2 \) evaluates to 1
- \((1+(4+5+2)-3)+(6+8)\) evaluates to 23
Your task is to read an expression from standard input and output the evaluated result to standard output.
inputFormat
The input consists of a single line containing the arithmetic expression. The expression may contain spaces, digits, parentheses, and the operators +, -, *, /.
For example:
3+2*2
outputFormat
Output a single integer which is the result of evaluating the expression.
For example:
7## sample
3+2
5
</p>