#K51682. Arithmetic Expression Evaluation
Arithmetic Expression Evaluation
Arithmetic Expression Evaluation
You are given a string representing an arithmetic expression. The expression consists of non-negative integers, the operators +
, -
, *
, and /
and may include parentheses ( )
. The operators follow the standard operator precedence: multiplication and division have higher precedence than addition and subtraction. When a division operation is encountered, perform integer division (i.e. truncate the fractional part).
For example, the expression (2+3)*4
should output 20
, and the expression 10+2*6-4/2
should output 20
.
Note: Use the following LaTeX notation for operator precedence: \(\ast,\div > +,-\).
inputFormat
The input is provided from standard input (stdin) as a single line containing a valid arithmetic expression, without any extra spaces or characters.
outputFormat
Print to standard output (stdout) a single integer which is the result of evaluating the given expression.
## sample3+5
8
</p>