您的位置:首页 > 其它

F - Addition and Subtraction Easy

2018-03-12 07:35 465 查看
注意一下输入,当时尝试了很多办法才解决的,我用了无关变量m和n存储空格

Problem Statement

Joisino wants to evaluate the formula "A op B". Here, A and B are integers, and the binary operator op is either 
+
 or 
-
. Your task is to evaluate the formula instead of her.
Constraints

1≦A,B≦109
op is either 
+
 or 
-
.
Input

The input is given from Standard Input in the following format:A op B
Output

Evaluate the formula and print the result.
Sample Input 1

1 + 2
Sample Output 1

3
Since 1+2=3, the output should be 3.
Sample Input 2

5 - 7
Sample Output 2

-2

#include<cstdio>
int main()
{
int a,c;
char b,n,m;
int sum;
while(scanf("%d",&a)!=EOF)
{
scanf("%c",&m);
scanf("%c",&b);
scanf("%c",&n);
scanf("%d",&c);
if(b==43)
{
sum=a+c;
printf("%d\n",sum);
}
else
{
sum=a-c;
printf("%d\n",sum);
}

}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: