#K75927. Arithmetic Expression Evaluation
Arithmetic Expression Evaluation
Arithmetic Expression Evaluation
You are given one or more arithmetic expressions consisting of non-negative integers, parentheses, and the operators \(+\), \(-\), \(\times\), and \(\div\). The expressions follow the usual order of operations (i.e. parentheses, multiplication and division, addition and subtraction). Note that \(\div\) represents integer division. For example, the expression 3+5*2
evaluates to 13
and the expression 10+2*6/2-4
evaluates to 12
.
You are to write a program that reads the number of cases followed by that many expressions; for each expression, compute and output the result.
The input will be provided via standard input and your output should be printed to standard output.
inputFormat
The first line of input contains a single integer \(T\) that indicates the number of test cases. The following \(T\) lines each contain a valid arithmetic expression. Expressions may contain spaces.
outputFormat
For each test case, output a single line containing the evaluated integer result of the expression.
## sample1
3+5*2
13
</p>