#C2358. Evaluate Mathematical Expressions
Evaluate Mathematical Expressions
Evaluate Mathematical Expressions
You are given a list of mathematical expressions. Each expression contains only non-negative integers and the operators + (addition) and * (multiplication). The multiplication operator has higher precedence than addition. Your task is to evaluate each expression and output its result.
For example, the expression 2+3*4 should be evaluated as 2+(3*4)=14.
Note: All the input expressions are guaranteed to be valid and will not contain any spaces.
The mathematical formula for each expression can be described in LaTeX as follows:
\( \text{result} = \sum_{i=1}^{n} \prod_{j=1}^{m_i} a_{ij} \)
inputFormat
The first line of input contains an integer T
denoting the number of expressions to evaluate.
Each of the following T
lines contains a single mathematical expression consisting of digits and the operators '+' and '*'.
Input is provided via standard input (stdin).
outputFormat
For each expression, output a single line containing the evaluated result.
Output should be sent to standard output (stdout).
## sample1
2+3*4
14
</p>