双11狂欢大促

盲盒赢 定制羽绒服

开启惊喜盲盒,抽取你的专属好礼

— 惊喜奖品抢先看 —

错哪了

木可大大 木可大大 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
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
我的代码是
#include <stdio.h>
#include<stdlib.h>
int main()
{
int n,temp=0,sum=0;
scanf("%d",&n);
while(n--)
{
scanf("%d",&temp);
while(temp)
{
sum+=temp;
printf("%d\n",sum);

}
}
return 0;
}
错哪了?
...全文

相关推荐

评论 11
收藏 已收藏
分享
返回顶部
木可大大
C语言 70,039 成员 243,237 内容