仅供参考,共同进步。

山科日记—A+B Problem

Description

计算a+b,0<=a,b<1000。

Input

输入有多对整数a和b组成,每对a和b占一行,a,b用空格分开。

Output

每行输出一个a+b的值,顺序与输入对应。

Sample Input

1 2
10 20

Sample Output

3
30

HINT

 

OJ系统上测试输入结束符为EOF(End Of File),其值为-1。用scanf()把文件所有内容读完后,会读到EOF,所以可以用来判断输入是否完成,测试时可以用Ctrl+Z产生EOF。本题解法参看FAQ。

 

Append Code

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main()
{
    int a, b;
    while(scanf("%d %d", &a, &b)!=EOF)
    {
        printf("%d\n", a+b);
    }
}

  

posted @ 2018-01-16 10:31  南山i  阅读(207)  评论(0编辑  收藏  举报