第一次编程练习第四题

第一次编程第四题

网站:https://vjudge.net/problem/hdu-1000?tdsourcetag=s_pctim_aiomsg

题目: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

#include<iostream>
using namespace std;
int main()
{
	int a,b;
	while (scanf("%d %d", &a, &b)!=EOF)
		printf("%d\n", a + b);
	return 0;
}

这题的目的很简单,但是有几点需要注意;
一、他的输入格式有限制,所以要用scanf;
二、题目规定了要计算很多组数据,所以在判断程序是否结束的时候用到了!=EOF来判断;
三、输出的格式要注意换行;

猜你喜欢

转载自blog.csdn.net/weixin_43508349/article/details/84846204