题目描述
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
思路
先解释一下题意吧:输入两个整数a和b,计算a与b的和,并输出。
听起来也没那么难~ 主要注意一下多组输入。
C语言代码:
#include<stdio.h>
int main()
{
int a , b;
while(scanf("%d %d",&a, &b) != EOF) //成功AC的关键
printf("%d\n",a + b);
return 0;
}
C++代码:
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a, b;
while(cin >> a >> b)
cout << a + b << endl;
return 0;
}