Calculate a + b
Input
The input will consist of a series of pairs of integers a and b,separated by a space, one pair of integers per line.
Output
For each pair of input integers a and b you should output the sum of a and b in one line,and with one line of output for each line in input.
Sample Input
1 5
Sample Output
6
Hint
Use + operator
Sample Program Here
C++:
#include<iostream>
using namespeace std;
int main(void)
{
int a,b;
while(cin>>a>>b)
cout<<a+b<<endl;//切记与题目要求输出格式一致
return 0;
}
C:
#include<stdio.h>
int main(void)
{
int a,b;
while(scanf("%d %d",&a,&b)!=EOF)//scanf失败的返回值为EOF
printf("%d\n",a+b);//切记与题目要求输出格式一致
return 0;
}
Ps:值得注意的一点是,千万不要因为对于A+B这样的一个问题的熟练,而不去仔细认真的读题,如果你仔细读题就会发现ZOJ的A+B问题是不同于传统的A+B问题,仅仅只是简单的两个数字相加,而是需要连续输入多个数字,谨记这次的刷题漏洞,一定记得读题。