A + B Problem
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 761778 Accepted Submission(s): 233759
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
注:水题,需要注意的是并不是只计算一组数据
#include<stdio.h>
int main()
{
int a, b;
int sum = 0;
while(scanf("%d %d", &a, &b) != EOF){
sum = a + b;
printf("%d\n", sum);
}
return 0;
}
本文介绍了一个经典的编程问题“A+B问题”,并提供了一段C语言代码示例,该问题要求读取多组整数A和B,输出它们的和。代码使用了while循环结合scanf检查文件结束标志来进行连续输入。
444

被折叠的 条评论
为什么被折叠?



