#C1002. Evaluate Arithmetic Expression
Evaluate Arithmetic Expression
Evaluate Arithmetic Expression
You are given an arithmetic expression in the form of a string containing non-negative integers, the binary operators +, -, *, and /, as well as parentheses to denote precedence. The division operator performs integer division. Your task is to evaluate the expression correctly following the standard arithmetic order of operations.
For example, given the expression 100 * ( 2 + 12 ) / 14
, you should compute:
You need to parse the expression, handle the operator precedence, and compute the result.
inputFormat
The input consists of a single line containing a valid arithmetic expression. The tokens (numbers, operators, and parentheses) in the expression are separated by a single space.
For example: 3 + 5
outputFormat
Output a single integer, the result of evaluating the given arithmetic expression.
## sample3 + 5
8