1135: 零起点学算法42——多组测试数据(求和)IV
1135: 零起点学算法42——多组测试数据(求和)IV
Time Limit: 1 Sec Memory Limit: 64 MB 64bit IO Format: %lld
Submitted: 2439 Accepted: 1277
[Submit][Status][Web Board]
Description
还有一些输入是以上几种情况的组合,具体根据题目对前面几种情况进行组合
比如题目要求是多组测试数据
每组测试数据首先输入一个整数n(如果n=0就表示结束) 然后再输入n个整数
这类题目输入格式如下:
int main()
{
int n,i;
while(scanf("%d",&n)!=EOF && n!=0)
{
for(i=1;i<=n;i++)
{
....//每次输入一个数,共循环n次,需要的时候做其他处理
} }
}
Input
Input contains multiple test cases. Each test case contains a integer N, and then N integers follow in the same line. A test case starting with 0 terminates the input and this test case is not to be processed.
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 
4 1 2 3 4
5 1 2 3 4 5
0
Sample Output
10
15
Source
#include<stdio.h>
int main(){
int n;
while(scanf("%d",&n)!=EOF&&n!=){
int a,s=;
for(int i=;i<=n;i++){
scanf("%d",&a);
s+=a;
}
printf("%d\n",s);
}
return ;
}
1135: 零起点学算法42——多组测试数据(求和)IV的更多相关文章
- Problem F: 零起点学算法42——多组测试数据输出II
#include<stdio.h> int main() { ; while(scanf("%d%d%d",&a,&b,&c)!=EOF) { ...
- 1137: 零起点学算法44——多组测试数据输出II
1137: 零起点学算法44--多组测试数据输出II Time Limit: 1 Sec Memory Limit: 64 MB 64bit IO Format: %lldSubmitted: ...
- 1136: 零起点学算法43——多组测试数据输出I
1136: 零起点学算法43--多组测试数据输出I Time Limit: 1 Sec Memory Limit: 128 MB 64bit IO Format: %lldSubmitted: ...
- 1134: 零起点学算法41——多组测试数据(a+b)III
1134: 零起点学算法41--多组测试数据(a+b)III Time Limit: 1 Sec Memory Limit: 64 MB 64bit IO Format: %lldSubmitt ...
- 1133: 零起点学算法40——多组测试数据(a+b)II
1133: 零起点学算法40--多组测试数据(a+b)II Time Limit: 1 Sec Memory Limit: 64 MB 64bit IO Format: %lldSubmitte ...
- 1132: 零起点学算法39——多组测试数据(a+b)
1132: 零起点学算法39--多组测试数据(a+b) Time Limit: 1 Sec Memory Limit: 64 MB 64bit IO Format: %lldSubmitted: ...
- Problem D: 零起点学算法40——多组测试数据(求和)IV
#include<stdio.h> int main() { int n,i,sum,a; ) { sum=; ;i<=n;i++) { scanf("%d",& ...
- 1164: 零起点学算法71——C语言合法标识符(存在问题)
1164: 零起点学算法71——C语言合法标识符 Time Limit: 1 Sec Memory Limit: 64 MB 64bit IO Format: %lldSubmitted: 10 ...
- 1145: 零起点学算法52——数组中删数II
1145: 零起点学算法52--数组中删数II Time Limit: 1 Sec Memory Limit: 64 MB 64bit IO Format: %lldSubmitted: 293 ...
随机推荐
- 每天一个Linux命令(09)--touch命令
linux的touch命令不常用,一般在使用make的时候可能会用到,用来修改文件时间戳,或者新建一个不存在的文件. 1.命令格式: touch [选项]··· 文件··· 2.命令参数: -a 或 ...
- Java原生API操作XML
使用Java操作XML的开源框架比较多,如著名的Dom4J.JDOM等,但个人认为不管你用那个框架都要对JDK原生的API有所了解才能更得心应手的应用.本篇就来简单了解下原生的XML API. JAV ...
- JS入门(四)
接之前一篇的函数.写之前的函数的时候讲的比较笼统,在这重新写一下函数的内容. 函数: 之前提过,函数就是代码复用的一种机制或是将代码封装成功能的代码段.函数的声明在这边就不多提了,因为相对来说比较简单 ...
- Struts2学习笔记②
之前在跟着老师们做项目的时候经常会烦恼Struts.xml怎么配置,老师也没讲太清楚,都是说很简单,但是不懂的人就是太难了!哈哈,万事还是要靠自己的! struts.xml今天又看了几个小时的书,也跟 ...
- Sort List leetcode
这个题一开始本想用快速排序的,但是想了20分钟都没有头绪,难点在于快速排序的随机访问无法用链表实现,不过如果可以实现快速排序partition函数就可以了,但是这可能比较复杂,于是改用其他排序方法,上 ...
- 通讯录--(适配iOS7/8/9)
导入库#import <AddressBook/AddressBook.h> #import <AddressBookUI/AddressBookUI.h> #pragma m ...
- PHP-配置方法
由于php是一个zip文件(非install版),安装较为简单,解压就行.把解压的 php5.2.1-Win32重命名为 php5.并复制到C盘目录下.即安装路径为 c:\php5 1 找到php目录 ...
- git remote log error
使用git pull的时候收到以下信息: error: there are still refs under 'refs/remotes/origin/xxxx'From 10.1.25.57:yyy ...
- ansj 2.0.7 错误例子分析
我在做一个solr的项目,分词选定了ansj分词. 选择ansj的原因: 1)身边若干朋友的念叨,说是效果不错 2)网上看了若干评论,说是不错 3)自己尝试了一些case,觉得确实不错. 好了,项目中 ...
- Linux命令语句秘籍
系统管理命令 stat 显示指定文件的详细信息,比ls更详细 who 显示在线登陆用户 whoami 显示当前操作用户 host ...