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
题目分析:
本题的重点是能多次输入数据实现运算,并不是输入一次,运算一次就退出程序了。
程序说明:
把cin>>a>>b当成while函数的参数就可以实现要求了,因为cin遇到输入终止的时候会返回一个0,而while遇到0时就会退出循环。
程序实现:
#include <iostream>
using namespace std;
int main()
{
int a, b;
while (cin >> a >> b)
{
cout << a + b << endl;
}
}