#K57212. Evaluate Algebraic Expression
Evaluate Algebraic Expression
Evaluate Algebraic Expression
You are given a string expr
representing an algebraic expression containing positive integers and the operators '+' and '-'. The expression follows the format:
\( \text{digit}{1,2} \big( [+-]\text{digit}{1,2} \big)^* \)
Your task is to compute the result of the expression. If the expression does not conform to the required format, output Invalid expression
.
For example, given the expression "10+20-5", the output should be 25.
inputFormat
The input consists of a single line containing the algebraic expression.
Input is provided via standard input.
outputFormat
Output the evaluation result of the expression as an integer, or output Invalid expression
if the input does not follow the required format.
Output should be printed to standard output.
## sample10+20-5
25