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

来源:互联网 发布:淘宝网如何注销 编辑:程序博客网 时间:2024/05/23 02:02

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..."


好了就是这样。。


0 0