ACM HDU 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
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的机制。