#C13210. Evaluate Simple Arithmetic Expression
Evaluate Simple Arithmetic Expression
Evaluate Simple Arithmetic Expression
You are given a string representing an arithmetic expression. The expression consists of positive integers and the operators +
and -
. The expression should be evaluated strictly from left to right, without any operator precedence rules. In other words, if the expression is given as
\(a+b-c+\cdots\)
then you should compute the result by performing each operation sequentially from left to right.
Note that if the input string is empty, the result is defined to be 0.
Your task is to write a program that reads an arithmetic expression from standard input (stdin) and outputs the evaluated result to standard output (stdout).
inputFormat
The input consists of a single line containing an arithmetic expression. The expression contains only digits and the operators +
and -
. If the input string is empty, treat it as an expression that evaluates to 0.
outputFormat
Output a single integer which is the result of evaluating the expression from left to right.
## sample5
5