HDOJ 1000 (C语言第一个程序~镇博之作)

来源:互联网 发布:mysql primary unique 编辑:程序博客网 时间:2024/05/09 03:51

A + B Problem

Problem 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
 


看了讨论区我才知道原来是可以循环输入的那种,谨记

 while(scanf("%d%d",&a,&b)!=EOF)

源代码

#include <stdio.h>
#include <stdlib.h>

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

 

1 0
原创粉丝点击