第二次卡

来源:互联网 发布:vod视频提取软件 编辑:程序博客网 时间:2024/04/28 19:56

题目:

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 with one line of output for each line in input. 

我的正确答案:

 #include<stdio.h>   int main(void)   {      int a,b=0,c,d=0,n,e=0;      while(scanf("%d",&n))  {  while(e<n) { while(scanf("%d",&c)){while(d<c){scanf("%d",&a);b=b+a;d++;}printf("%d%\n",b);d=0;b=0;} e++; }  }   }
感觉很繁琐,其实我前面想着简化一下,可是学识有限,无从下手,如果哪位大佬愿意带带我,当然是最好不过啦。

这道题其实没什么要注意的,主要是记住每次循环时累加器要清零就可以啦。

0 0
原创粉丝点击