Banner Home Page DIY Contests Problems Ranklist Status Statistics
1034数据再次加强,如果还能水过我不管了……

多数据处理——文件结束

Time Limit : 3000/1000ms (Java/Other)   Memory Limit : 65535/32768K (Java/Other)
Total Submission(s) : 89   Accepted Submission(s) : 63

Font: Times New Roman | Verdana | Georgia

Font Size:

Problem Description

有些题目要在同一个程序处理多组数据,就涉及到如何处理这样的数据
第一类:EOF 文件结束
C++处理方式,使用while循环控制输入,当到达文件结束,即没有输入时,程序将终止
int main()
{
  int a, b;
  while( cin >> a >> b ){
    //program
  }
  return 0;
}
C处理方式,使用EOF判断,当读到文件结束时,scanf返回EOF
int main()
{
  int a, b;
  while( scanf( “%d%d”, &a, &b ) != EOF ) {
    //program
  }
  return 0;
}
结合以上内容,或查找相关资料,处理多输入的a+b问题

Input

输入包含多组数据 ( Input contains multiple test cases. )
每组数据包含两个整数a,b ( 1 <= a, b <= 10 )

Output

对于每组数据,输出a+b的值

Sample Input

1 1
2 3

Sample Output

2
5

Author

916852

Statistic | Submit | Back