#K77682. Evaluate Arithmetic Expression
Evaluate Arithmetic Expression
Evaluate Arithmetic Expression
Given a string representing a valid arithmetic expression, evaluate it and print the result. The expression contains integer numbers, the binary operators +
, -
, *
, /
, and may include parentheses (
and )
. Whitespaces between characters should be ignored.
Operator precedence follows the standard rules. In particular, multiplication and division have a higher precedence than addition and subtraction. Division is defined as truncating division, i.e., for any integers \(a\) and \(b\) (with \(b \neq 0\)), $$\text{result} = \text{trunc}(a/b)$$ where \(\text{trunc}(\cdot)\) truncates towards zero.
Your task is to compute and output the integer result of the evaluated expression.
inputFormat
A single line is given via standard input, representing a valid arithmetic expression. The expression consists of non-negative integers, the operators +, -, *, /, parentheses, and may contain extra spaces.
outputFormat
Print a single integer to standard output, which is the result of evaluating the given arithmetic expression.## sample
3+2
5
</p>