c语言实现多行输入输出数据

刷题中遇到的要求多行输入与输出

链接:https://ac.nowcoder.com/acm/contest/5649/A
来源:牛客网

题目描述
计算a+b

输入描述:
输入包括两个正整数a,b(1 <= a, b <= 10^9),输入数据包括多组。
输出描述:
输出a+b的结果

示例1
输入
1 5
10 20
输出
6
30

方法:采用while循环控制输入的继续或停止

//while循环控制1
#include<stdio.h>
int main()
{
    
    
    int a,b;
    while(~scanf("%d %d",&a,&b))
    {
    
    
        printf("%d\n",a+b);
    }
    return 0;
}

//while循环控制1
#include<stdio.h>
int main ()
{
    
    
    int a,b;
    while(scanf("%d %d",&a,&b)!=EOF){
    
    
        printf("%d\n",a+b);
    }
    return 0;
}

猜你喜欢

转载自blog.csdn.net/shiwujigegea/article/details/108442124