您的位置:首页 > 编程语言 > C语言/C++

理工大学ACM平台题答案关于C语言 1017 A+B for Input-Output Practice

2013-12-20 21:36 507 查看

A+B for Input-Output Practice


Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里^_^

题目描述

Your task is to calculate the sum of some integers

输入

Input contains an integer N in the first line, and then N lines follow. Each line starts with a integer M, and then M integers follow in the same line

输出

For each group of input integers you should output their sum in one line, and you must note that there is a blank line between outputs.

示例输入

3
4 1 2 3 4
5 1 2 3 4 5
3 1 2 3


示例输出

10

15

6



#include<stdio.h>

void main()

{

int i,j,k,l,sum[100],summ=0,m,count=0;

scanf("%d",&i);

for(j=0;j<i;j++)

{

scanf("%d",&k);

for(l=0,summ=0,m=0;l<k;l++)

{

scanf("%d",&m);

summ=summ+m;

}

sum[j]=summ;

count++;

}

for(j=0;j<count-1;j++)

{

printf("%d\n\n",sum[j]);

}

printf("%d",sum[count-1]);

}

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐