#K90942. Evaluate Arithmetic Expression
Evaluate Arithmetic Expression
Evaluate Arithmetic Expression
You are given an arithmetic expression in the form of a string. The expression contains single-digit integers and binary operators '+' and '-' (minus). All tokens (numbers and operators) in the expression are separated by exactly one space. Your task is to evaluate the expression and output the result.
For instance, if the expression is given as:
3 + 5 - 2
Then the output should be:
6
You can interpret the evaluation as performing left-to-right operations:
\( result = a \pm b \pm c \pm \ldots \)
It is guaranteed that the expression is well-formed.
inputFormat
The input consists of a single line containing the arithmetic expression. The expression has the format:
digit operator digit operator digit ...
Each token is separated by a single space.
outputFormat
Output a single integer which is the result of the evaluated expression.
## sample3 + 5
8