#C13268. Arithmetic Expression Evaluation
Arithmetic Expression Evaluation
Arithmetic Expression Evaluation
Given a mathematical expression as a string, evaluate its integer result. The expression may include non-negative integers, the operators \(+, -, \times, \div\) and parentheses. You are required to follow the standard operator precedence: evaluate expressions inside parentheses first, followed by multiplication and division, and finally addition and subtraction. Note that division should truncate towards zero. For example, the expression 3+2*2
should evaluate to 7
.
inputFormat
The input is provided via standard input (stdin) as a single line containing a valid mathematical expression. The expression will only include non-negative integers, the operators +
, -
, *
, /
, parentheses, and possibly spaces.
outputFormat
Output the computed integer result of the expression to standard output (stdout).
## sample3+2
5