HDU - 1000 A + B Problem

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;
}
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容