No.222 Subtraction and Addition
Problem Statement
A sensible person would interpret the string "x+y" as x + y and the string "x-y" as x - y.
However, Alice has addition and subtraction mixed up.
That is, she interprets the string "x+y" as x - y and the string "x-y" as x + y.
Given an input string, output the result of the operation under Alice's interpretation.
Input
$x$$op$$y$
$-10000 \le x \le 10000$
$op$ is "+" or "-"
$-10000 \le y \le 10000$
$x$,$y$ are integers and may have a leading sign (+,-).
(For example, if the integer is 0, there are 3 possible inputs: +0,-0,0.
If the integer is 1, there are 2 possible inputs: +1,1.
If the integer is -1, there is 1 possible input: -1.)
Output
Output the resulting value on one line. Print a newline at the end.
Sample
Sample 1
Input
5+3
Output
2
The input is 5+3, but output 2, which is the result of the operation 5 - 3.
Sample 2
Input
10-20
Output
30
Sample 3
Input
-2+-3
Output
1
The input x,y may include signs.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
shimomire