一道很简单的C语言练习题 我想看看是不是我理解错题目了

ProblemDescriptionYourtaskistoCalculatea+b.Tooeasy?!Ofcourse!Ispeciallydesignedthepro... Problem Description

Your task is to Calculate a + b.
Too easy?! Of course! I specially designed the problem for acm beginners.
You
must have found that some problems have the same titles with this one,
yes, all these problems were designed for the same aim.

Input

The input will consist of a series of pairs of integers a and b, separated by a space, one pair of integers per line.

Output

For
each pair of input integers a and b you should output the sum of a and b
in one line, and with one line of output for each line in input.

Sample Input
1 5
10 20

Sample Output
6
30

谁帮我写出这个题目的代码 我比较自己的看一下 谢谢 求不鄙视
请问这里的Sample Input 和 Ooutput意思是不是一次性输入四个数 然后一次性输出两个结果?
展开
 我来答
濮方雅BX
2015-04-02 · TA获得超过4041个赞
知道大有可为答主
回答量:2482
采纳率:60%
帮助的人:2423万
展开全部
#include<iostream>
using namespace std;
int main(){
    int a,b;

while(cin>>a>>b)cout<<a+b<<endl;
    return 0;

}


请问这里的Sample Input 和 Ooutput意思是不是一次性输入四个数 然后一次性输出两个结果?

——是样例输入输出,用来告诉你输入和输出的格式,实际的用于测试你程序是否正确的数据可能远比这个要多

匿名用户
2015-04-02
展开全部
是一次性输入,也是一次性输出的。
#include <stdio.h>
int main()
{
int a,b,c,d,sum1,sum2;

scanf("%d %d %d %d",&a,&b,&c,&d);
sum1=a+b;
sum2=c+d;
printf("%d\n%d",sum1,sum2);

return 0;
}
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
陌上行走life
2015-04-02
知道答主
回答量:2
采纳率:0%
帮助的人:2.2万
展开全部
#include<stdio.h>
int main()
{
int a,b,sum;
while(scanf("%d %d",&a,&b))
{
sum=a+b;
printf("%d\n",sum);
}
return 0;
}
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
Aurora粽
2018-10-22 · 既一知半解,你又何必敷衍作答,误人误己呢
Aurora粽
采纳数:12 获赞数:379

向TA提问 私信TA
展开全部
#include <stdio.h>

int main()
{
int a,b;

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

return 0;
}
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 1条折叠回答
收起 更多回答(2)
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式