杭电的acm的题A+B for Input-Output Practice (IV)
求解啊ProblemDescriptionYourtaskistoCalculatethesumofsomeintegers.InputInputcontainsmult...
求解啊
Problem Description
Your task is to Calculate the sum of some integers.
Input
Input contains multiple test cases. Each test case contains a integer N, and then N integers follow in the same line. A test case starting with 0 terminates the input and this test case is not to be processed.
Output
For each group of input integers you should output their sum in one line, and with one line of output for each line in input.
Sample Input
4 1 2 3 4
5 1 2 3 4 5
0
Sample Output
10
15 展开
Problem Description
Your task is to Calculate the sum of some integers.
Input
Input contains multiple test cases. Each test case contains a integer N, and then N integers follow in the same line. A test case starting with 0 terminates the input and this test case is not to be processed.
Output
For each group of input integers you should output their sum in one line, and with one line of output for each line in input.
Sample Input
4 1 2 3 4
5 1 2 3 4 5
0
Sample Output
10
15 展开
1个回答
展开全部
学习一下输入输出就好,欢迎交流。
#include<stdio.h>
int main()
{
int n,x,sum;
while(scanf("%d",&n)&&n!=0)
{
sum = 0;
while(n--)
{
scanf("%d",&x);
sum+=x;
}
printf("%d/n",sum);
}
return 0;
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
富港检测技术(东莞)有限公司_
2024-08-05 广告
2024-08-05 广告
作为富港检测技术(东莞)有限公司的工作人员,关于ISTA 1A、2A及3A的区别及测试项目简述如下:ISTA 1A是非模拟集中性能试验,主要进行固定位移振动和冲击测试,针对不超过68kg的包装件。ISTA 2A则在此基础上增加了部分模拟性能...
点击进入详情页
本回答由富港检测技术(东莞)有限公司_提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询