#C8574. Evaluate Mathematical Expression
Evaluate Mathematical Expression
Evaluate Mathematical Expression
This problem requires you to evaluate a mathematical expression provided as a string. The expression contains non-negative integers and the operators +
, -
, and *
. The standard operator precedence applies, i.e., multiplication has higher precedence than addition and subtraction. Specifically, if the expression is denoted by \(E\), then the evaluation follows:
\( E = \text{number} \; ( ( + | - | * ) \; \text{number} )^* \)
For example, the expression "3+5*2-4" should be evaluated as \(3 + (5 \times 2) - 4 = 9\).
You need to output the computed integer result of the expression.
inputFormat
Input is provided via stdin as a single line string containing the mathematical expression. The expression will consist only of digits and the operators '+', '-', '*'. There are no spaces in the input.
outputFormat
Output a single integer to stdout which is the result of the evaluated expression.## sample
3+5
8