杭电的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-09-01 广告
2024-09-01 广告
电学测试台是深圳市华芯测试科技有限公司的核心设备之一,它集成了高精度测量仪器与自动化控制系统,专为半导体芯片、电子元件及模块的电性能检测而设计。该测试台能够迅速、准确地完成电压、电流、电阻、电容及频率等关键参数的测试,确保产品质量符合行业标...
点击进入详情页
本回答由华芯测试提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询