#C12358. Evaluate Arithmetic Expression
Evaluate Arithmetic Expression
Evaluate Arithmetic Expression
You are given a string representing a mathematical expression containing non-negative integers, operators +, -, *, /, and parentheses. The expression may include spaces. Your task is to compute the result of the expression using integer arithmetic (i.e. integer division is applied for the division operator). For example, the expression 3+(2*2)
evaluates to 7
.
The evaluation follows the standard operator precedence rules:
- Addition and subtraction: $+$ and $-$, with precedence 1.
- Multiplication and division: $\times$ and $\div$, with precedence 2.
inputFormat
The input is provided as a single line from stdin which contains the string expression to be evaluated. The expression may contain spaces.
Format: a single line string.
outputFormat
Output the evaluated integer result to stdout.
Format: a single integer.
## sample3+(2*2)
7