HDOJ 1000 A + B Problem
Problem Description
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<stdio.h>
int main(void)
{
int a, b;
while ((scanf("%d %d", &a, &b)) != EOF)//scanf函数检测到文件结尾时会返回EOF也就是-1;
/*EOF是C语言的文件结束符是end of file的缩写被定义在stdio.h头文件中代码是#define EOF (-1)是个宏定义,
EOF的值为-1.也就是说EOF等价于-1,代码中EOF可以完全用-1替换,但并不推荐那么做,会影响代码可读性。*/
printf("%d\n", a + b);//别忘了这里有个换行的
return 0;
}