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
Sample Output
Author
HDOJ
解题思路:非常简单的一道水题,输入两个整数,输出整数的和。
代码如下 (C语言)
#include <stdio.h>
int main(void)
{
int a, b;
int sum,ch;
while ((ch = scanf_s("%d %d", &a, &b)) == 2)
{
sum = a + b;
printf("%d\n", sum);
}
return 0;
}
本来以为需要EOF判断结束的,没想到这样成功了。还是不明白AC的机制。
ACM HDU 1000
原文:http://www.cnblogs.com/WLHBlog/p/7565247.html