#C12357. Evaluate Arithmetic Expression
Evaluate Arithmetic Expression
Evaluate Arithmetic Expression
Given a string representing a mathematical expression, evaluate it and output the result as an integer. The expression contains non-negative integers and the operators +
, -
, *
, and /
. The operator /
represents integer division, and standard operator precedence applies: multiplication and division have higher precedence than addition and subtraction. In formulas, multiplication is denoted by \(\times\) and division by \(\div\).
For example, the expression:
$$3+5\times2$$
evaluates to 13.
inputFormat
The input consists of a single line containing a string expression without spaces. The string represents a valid arithmetic expression using non-negative integers and the operators +
, -
, *
, and /
.
outputFormat
Output a single integer which is the result of evaluating the expression. Note that division is performed as integer division.
## sample3+5*2
13