1.1.5
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.

Sample Input
2
4 1 2 3 4
5 1 2 3 4 5

Sample Output
10
15

#include <stdio.h>
int main()
{
int n,i,a,new,sum=0;
scanf("%d",&n);
i=0;
while (~scanf("%d",&a)&&i<n)
{
while(a--)
{
scanf("%d",&new);
sum+=new;
}
printf("%d\n",sum);
i++;
sum=0;/*一定要把sum重新置零,不然会
带着上一行输入的sum继续做加法*/
}
return 0;
}

也改了许多次才通过.需要特别注意注释处的细节
还有,学到方法while(a–)来代替计数器.

最新文章

  1. 基于XML的AOP配置-转
  2. Android Programming: Pushing the Limits -- Chapter 7:Android IPC -- AIDL
  3. [New Portal]Windows Azure Virtual Machine (10) 自定义Windows Azure Virtual Machine模板
  4. Spring中@Component注解,@Controller注解详解
  5. JS常用各种正则表达式
  6. hdu 1829-A Bug&#39;s LIfe(简单带权并查集)
  7. 文件夹同步/备份软件推荐 (SyncToy/FreeFileSync/Compare Advance/GoodSync/Allway Sync/Compare Advance)
  8. Python 文件操作模块 shutil 详解
  9. python 遍历字典
  10. 关于bootstrap弹出二级对话框的使用
  11. php获胜的算法的概率,它可用于刮,大转盘等彩票的算法
  12. javascript遍历select下拉框判断其中值是否与指定值相等
  13. hdu4284之字典树
  14. &lt;C++Primer&gt;第四版 阅读笔记 第一部分 “基本语言”
  15. JStorm与Storm源码分析(五)--SpoutOutputCollector与代理模式
  16. Java I/O 从0到1 - 第Ⅰ滴血 File
  17. 优雅地实现CSS Animation delay
  18. win10 vscode使用 智能提示
  19. 发布core到linux
  20. CodeForces1073E 数位dp+状压dp

热门文章

  1. k8s控制器和Pod Template的关系
  2. css自定义会话框
  3. day05多表查询01
  4. PHP全栈开发(八):CSS Ⅳ 文本格式及字体
  5. PHP全栈开发(一):CentOS 7 配置LAMP
  6. POJ1681 Painter&#39;s Problem(高斯消元)
  7. MergeOption.NoTracking的使用
  8. 『现学现忘』Git基础 — 36、标签tag(一)
  9. 虚拟化_Xen——敬请期待!
  10. Springboot+vue 实现汽车租赁系统(毕业设计二)(前后端项目分离)