#C14113. Evaluate Mathematical Expression
Evaluate Mathematical Expression
Evaluate Mathematical Expression
You are given a string representing a mathematical expression composed solely of non-negative integers, the plus sign +
and the multiplication sign *
. The evaluation must follow the standard operator precedence rules, i.e., multiplication is performed before addition. The numbers in the expression can have multiple digits.
For example, the expression 3+2*2
evaluates to 7 because the multiplication is executed first: \(3 + (2 \times 2) = 7\).
Your task is to compute the result of the given expression.
Input Format: A single line containing the expression.
Output Format: A single integer representing the evaluated result.
inputFormat
The input consists of a single line containing a string expression which includes digits (0-9), the addition operator +
, and the multiplication operator *
.
It is guaranteed that the expression is valid and does not contain any spaces or other characters.
outputFormat
Output a single integer which is the result of evaluating the expression according to standard operator precedence. In particular, the multiplication operation is performed before the addition.
## sample3+2*2
7