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

时间:2022-12-28 09:04:24

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;
}