#C7684. Evaluate Mathematical Expression
Evaluate Mathematical Expression
Evaluate Mathematical Expression
You are given a non-empty string representing a mathematical expression. The expression contains non-negative integers, the operators +, -, *, /, and parentheses ( )
. Evaluate the expression following the standard operator precedence rules and using left-to-right associativity. Note that the division operator performs integer division (i.e. it truncates toward zero).
For example, the expression 3 + 2 * 2
evaluates to 7, and the expression (2+6)/2
evaluates to 4.
The expression is guaranteed to be valid.
inputFormat
The input consists of a single line containing a non-empty string s
that represents a mathematical expression. The string may include spaces.
outputFormat
Output a single integer representing the evaluated result of the expression.
## sample3+2*2
7