天天看点

HDU-1000 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.

SampleInput

1 1

Sample Output

2

解题思路: 题中只给出一个样例,根据格式来看,为持续输入,没有规定多少组数,可以使用scanf函数的返回值来判断,是否还在输入。 代码如下

#include
int main()
{ 
  int a,b,d=0;
  while(scanf("%d%d",&a,&b)!=EOF)
  { 
     d=a+b;
     printf("%d\n",d); 
   } 
   return 0;
}      

继续阅读