标题:此程序如何编写 是利用数组嘛, 请各位指路
取消只看楼主
A16310320524
Rank: 1
等 级:新手上路
帖 子:5
专家分:5
注 册:2016-11-1
结帖率:100%
已结贴  问题点数:10 回复次数:2 
此程序如何编写 是利用数组嘛, 请各位指路
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
搜索更多相关主题的帖子: multiple starting follow should 
2016-11-01 16:36
A16310320524
Rank: 1
等 级:新手上路
帖 子:5
专家分:5
注 册:2016-11-1
得分:0 
回复 2楼 linlulu001
程序是错误的
2016-11-01 23:29
A16310320524
Rank: 1
等 级:新手上路
帖 子:5
专家分:5
注 册:2016-11-1
得分:0 
#include<stdio.h>
int main()
{
    int n,i,sum;
    int a[100];
    while(~scanf("%d",&n))
    {
        sum=0;
        if(n==0)
        return 0;
        else
        {
            for(i=0;i<n;i++)
    {
    scanf("%d",&a[i]);
    sum+=a[i];
     }
     printf("%d\n",sum);
    }
        }
    return 0;
 }
/*应该可以吧 你试试*/

[此贴子已经被作者于2017-2-12 18:17编辑过]

2017-02-12 18:16



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-470569-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.670101 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved