一道很简单的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意思是不是一次性输入四个数 然后一次性输出两个结果? 展开
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意思是不是一次性输入四个数 然后一次性输出两个结果? 展开
4个回答
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;
}
#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;
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
#include<stdio.h>
int main()
{
int a,b,sum;
while(scanf("%d %d",&a,&b))
{
sum=a+b;
printf("%d\n",sum);
}
return 0;
}
int main()
{
int a,b,sum;
while(scanf("%d %d",&a,&b))
{
sum=a+b;
printf("%d\n",sum);
}
return 0;
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
#include <stdio.h>
int main()
{
int a,b;
while(scanf("%d%d",&a,&b)!=EOF)
{
printf("%d\n",a+b);
}
return 0;
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询