HDU 1096

来源:互联网 发布:网络舆情监测专业 编辑:程序博客网 时间:2024/06/04 20:07

A+B for Input-Output Practice (VIII)

Problem Description
Your task is to calculate the sum of some integers.
 
Input
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. 

还是累加,只不过输出是每个之间输出一个空行,最后一个数据后面没有空行。

#include<stdio.h>int main (){    int s[100],i,n,sum,t,j,u;    while (scanf ("%d",&t)!=EOF)    {           for(j=0;j<t;j++)        {            scanf ("%d",&n);            sum=0;            for (i=0;i<n;i++)            {                scanf("%d",&u);                 sum=sum+u;            }             s[j]=sum;        }                  for (j=0;j<t;j++)        {            if(j==t-1)            printf ("%d\n",s[j]);            else        printf ("%d\n\n",s[j]);        }            }    return 0;}


1 0
原创粉丝点击