#C6197. Evaluate Mathematical Expression
Evaluate Mathematical Expression
Evaluate Mathematical Expression
You are given a string representing a mathematical expression containing non-negative integers and the operators +
, -
, and *
. The expression does not contain any spaces. Your task is to evaluate the expression and print its result as an integer. The operator *
has higher precedence than +
and -
. Use the standard order of operations!
The evaluation should follow the rules: \[ \text{Multiplication (*) has a higher precedence than Addition (+) and Subtraction (-)} \]
For example, the expression 3+5*2-6
is evaluated as 3 + (5*2) - 6 = 7
.
inputFormat
The input consists of a single line containing the expression string.
For example: 3+5*2-6
outputFormat
Output a single integer representing the evaluated result of the expression.
For example, for the input above the output should be: 7
3+5*2-6
7