#C12809. Evaluate Mathematical Expressions
Evaluate Mathematical Expressions
Evaluate Mathematical Expressions
Given a list of mathematical expressions, evaluate each expression and output the result. Each expression consists of non-negative integers and the operators + (addition), - (subtraction), and * (multiplication). Operator precedence must be respected, i.e., multiplication is evaluated before addition and subtraction. There are no parentheses in the expressions.
For example, the expression "2 + 3 * 4 - 5" should be evaluated as \(2 + (3 \times 4) - 5\) = 9.
inputFormat
The first line contains an integer \(n\) indicating the number of expressions. Each of the following \(n\) lines contains a single mathematical expression.
outputFormat
Output \(n\) lines, each line containing the integer result of the corresponding expression in the input.
## sample1
2 + 3
5
</p>