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
问题链接(https://vjudge.net/problem/hdu-1000?tdsourcetag=s_pctim_aiomsg)
问题简述:实现简单的加法运算,对输入的A,B值进行加法计算并输出结果
程序分析:由于题目要求对多行数据进行计算,所以循环体的条件为cin>>a>>b;即当输入Ctrl+z时停止程序;
AC的C++代码如下
#include<iostream>
using namespace std;
int main()
{
int a,b;
while (cin >> a >> b)
{
cout<< a + b << endl;
}
return 0;
}
网友评论