关闭

A+B for Input-Output Practice (VIII)

标签: A+B杭电入门
341人阅读 评论(0) 收藏 举报
分类:

A+B for Input-Output Practice (VIII)

Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Other)
Total Submission(s) : 57   Accepted Submission(s) : 13

Font: Times New Roman | Verdana | Georgia

Font Size:  

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. 

Output

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.

Sample Input

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

Sample Output

10

15

6

Author

lcy

相比前面的题目就是增加了格式细节问题,呵呵、
#include <stdio.h>
int main()
{
    int a,sum,n,i,j,m;
    scanf("%d",&m);
    for(j=0;j<m;j++)
    {
if(j!=0) printf("\n");        
scanf("%d",&n);
        sum=0;
        for(i=0;i<n;i++)
        {
            scanf("%d",&a);
            sum+=a;
        }
        printf("%d\n",sum);
    }
    return 0;
}


0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:13308次
    • 积分:16
    • 等级:
    • 排名:千里之外
    • 原创:25篇
    • 转载:0篇
    • 译文:0篇
    • 评论:0条
    文章分类