#C12360. Evaluate Mathematical Expression
Evaluate Mathematical Expression
Evaluate Mathematical Expression
You are given a string expression
that represents a mathematical expression containing non-negative integers and the operators +
and *
. The expression must be evaluated following the standard order of operations, where multiplication is performed before addition.
For example, the expression 3+5*2
is evaluated as 3+(5*2)=13
.
Your task is to write a program that reads an expression from standard input, evaluates it, and prints the result to standard output.
Note: The expression does not contain any spaces, and it is guaranteed to be a valid expression.
inputFormat
The input consists of a single line containing the expression.
For example:
3+5*2
outputFormat
Output the evaluated result as an integer.
For example, for the input above, the output should be:
13## sample
3+5
8