#C14601. Evaluate Mathematical Expression
Evaluate Mathematical Expression
Evaluate Mathematical Expression
You are given a string representing a mathematical expression. The expression contains non-negative integers, the addition operator (+
), the subtraction operator (-
), and may include spaces. Your task is to evaluate the expression and output the result.
The expression adheres to the following format: \(number \; [+, -] \; number \; [+, -] \; number \; ...\). Operators are processed sequentially from left to right (i.e. no operator precedence is applied), and there are no parentheses in the expression.
inputFormat
A single line from standard input containing the mathematical expression.
outputFormat
A single integer printed to standard output, which is the result of evaluating the expression.## sample
10 + 20 - 5 + 3
28