您的位置:首页 > 其它

acm从基本开始--熟悉输入输出HDU1000 A+B

2015-02-25 23:06 363 查看
A - A + B Problem
Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u
Submit Status Practice HDU
1000

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


分析:好吧这个题没什么分析的。。(我不会说这篇文章是用来试一试CSDN的博客功能的。。)明白ACM导入测试数据的方式是多组的,这个跟题目叙述有一点关系,具体落实到代码如下:

#include <iostream>
using namespace std;
int main()
{
int a,b;
while(cin>>a>>b)
{
cout<<a+b<<endl;
}
}


就是那个while的问题。

此外还有while(scanf("%d%d",a,b)!=EOF),也是可以的,对应的题目表述是"The input of the problem consists several test cases..."

好了就是这样。。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: