Calculate A + B
Time limit:1000 ms Memory limit:32768 kB
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
Output
2
问题简述:
输入A+B并输出他们的和,每行都要包含A,B,处理到文件结尾。
*问题分析:
不可以将cin单独放一行,可以用while输入和输出。
程序说明:
将cin放在while中进行输入,并在while内输出,达到目的。
c++语言程序如下:
#include "pch.h"
#include <iostream>
using namespace std;
int main()
{
int A, B;
cout << "请输入A,B:";
while (cin >> A >> B)
cout << "A+B=" << A + B << endl;
}