标题:谁帮我看一下一道简单的ACM题目
只看楼主
kolnick
Rank: 2
等 级:论坛游民
帖 子:24
专家分:13
注 册:2009-6-24
结帖率:100%
 问题点数:0 回复次数:2 
谁帮我看一下一道简单的ACM题目
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 with one line of output for each line in input.



下面是我做的代码
#include"stdio.h"
main()
{
int n,i,k,j,sum=0;
 scanf("%d",&n);
 for(i=1;i<=n;i++)
 {
    sum=0;
   scanf("%d",&k);
   for(j=1;j<=k;j++)
   {
     scanf("%d",&j);
     sum+=j;
   }
   printf("%d\n",sum);
 }
}

感觉我的思路是对的但是提交上去还是错 不知道错在那里!!  请大家 帮我看一下谢谢了
搜索更多相关主题的帖子: ACM 
2010-11-07 11:42
outsider_scu
Rank: 9Rank: 9Rank: 9
等 级:蜘蛛侠
威 望:3
帖 子:430
专家分:1333
注 册:2010-10-21
得分:0 
哪的OJ?
程序代码:
#include"stdio.h"
main()
{
int n,i,k,j,sum=0,num;
scanf("%d",&n);
for(i=1;i<=n;i++)
{
    sum=0;
   scanf("%d",&k);
   for(j=1;j<=k;j++)
   {
     scanf("%d",&num);
//定义一个num;要不然你就篡改变量j了
     sum+=num;
   }
   printf("%d\n",sum);
}
}

编程的道路上何其孤独!
2010-11-07 12:44
kolnick
Rank: 2
等 级:论坛游民
帖 子:24
专家分:13
注 册:2009-6-24
得分:0 
谢谢美女!
2010-11-08 11:13



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-325240-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 1.850151 second(s), 7 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved