No.708 (+-) Expression
Problem Statement
You are given a (+-) expression $S$.
Evaluate it.
Here, a (+-) expression is an expression that satisfies the following conditions.
・It consists only of '+', '-', '(', ')', and the digits '0' to '9'.
・'(' and ')' correspond one-to-one, and parentheses are nested at most one level deep.
That is, '(' and ')' appear the same number of times, and after a '(', another '(' never appears before a ')' comes.
・Two or more digits never appear consecutively.
・Two or more signs never appear consecutively.
"4-(2-1)" satisfies the conditions and is therefore a (+-) expression, but "4*2-1/1", "4.2+3", "(7-(7+7))", "77+7", and "4+-3" are not.
Input
$S$
The input consists of one line,
in which $S(1 \leq |S| \leq 100)$ representing the problem
is given.
Output
Output the result of the calculation. Insert a newline at the end.
Sample
Sample 1
Input
3+4-2
Output
5
It is a well-known fact that $3+4-2=5$.
Sample 2
Input
3-(1-1)
Output
3
It is also a well-known fact that $3-(1-1)=3$.
Sample 3
Input
1-(2-1)+(2+2)-3
Output
1
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
37zigen