一道很简单的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
谁帮我写出这个题目的代码 我比较自己的看一下 谢谢 求不鄙视 展开
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
谁帮我写出这个题目的代码 我比较自己的看一下 谢谢 求不鄙视 展开
2个回答
展开全部
#include "stdio.h"
void main()
{
int n,i=0,j=0,a[100],x,y;
printf("请输入次数\n");
scanf("%d",&n);
while(i!=n)
{
printf("请输入两个数:\n");
scanf("%d%d",&x,&y);
a[i]=x+y;
i++;
}
while(j<n)
{
getchar();
printf("%d ",a[j]);
j++;
}
}
void main()
{
int n,i=0,j=0,a[100],x,y;
printf("请输入次数\n");
scanf("%d",&n);
while(i!=n)
{
printf("请输入两个数:\n");
scanf("%d%d",&x,&y);
a[i]=x+y;
i++;
}
while(j<n)
{
getchar();
printf("%d ",a[j]);
j++;
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2015-04-02
展开全部
#include<stdio.h>
main()
{
int a,b;
while(scanf("%d%d",&a,&b)!=EOF)
printf("%d\n\r",a+b);
}
main()
{
int a,b;
while(scanf("%d%d",&a,&b)!=EOF)
printf("%d\n\r",a+b);
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询