a+b

Ambosqinglan 2019-03-22 06:03:50
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.
C语言新手求解!
...全文
54 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
lin5161678 2019-03-23
  • 打赏
  • 举报
回复
所以 你的问题呢?
刘蕘 2019-03-22
  • 打赏
  • 举报
回复
#include <stdio.h> #include <stdlib.h> //主要你没给例子 //是要3 1 2 3这样的输入 输出6吗 int main() { int sum,n,a[100],i;//a改成数组 while(scanf("%d",&n)&&n!=0){//这里条件符号 sum=0; for(i=0;i<n;i++){ scanf("%d",&a[i]); sum+=a[i]; } printf("%d\n",sum); } return 0; }
marwi_study 2019-03-22
  • 打赏
  • 举报
回复
这是我根据题目要求写的一个程序

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int sum,n,a,i;
    while(scanf("%d",&n),n!=0){
        sum=0;
        for(i=0;i<n;i++){
            scanf("%d",&a);
            sum+=a;
        }
        printf("%d\n",sum);
    }
    return 0;
}

69,336

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧