Problem Description
Calculate A + B.
Input
Each line will contain two integers A and B. Process to end of file.
Output
For each case, output A + B in one line.
Sample Input
1 1
Sample Output
2
这是一道水题,很简单的。但是要注意输入的是多行,要用到while(scanf(“%d%d”,&a,&b)!=EOF)这一条语句
#include <iostream>
#include <stdio.h>
using namespace std;
int main()
{
int a, b;
int sum;
while(scanf("%d%d",&a,&b)!=EOF)
{
sum=0;
sum=a+b;
printf("%d\n",sum);
}
return 0;
}
结果