新手入门--输入格式四
来源:互联网 发布:软件疲劳强度测试 编辑:程序博客网 时间:2024/04/25 23:58
新手入门
输入格式四:
A+B for Input-Output Practice (IV)
Problem Description
Your task is to Calculate the sum of some integers.
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 45 1 2 3 4 50
Sample Output
1015
注:每组数据前都有一个数提示,当一行第一个数为0,输入结束。
代码:
#include<stdio.h>int main(){ int n,i,sum,a; while(scanf("%d",&n)&&n!=0){ sum=0; for(i=0;i<n;i++){ scanf("%d",&a); sum+=a; } printf("%d\n",sum); } return 0;}
0 0
- 新手入门--输入格式四
- 新手入门--输入格式二
- 新手入门--输入格式三
- 新手入门--输入格式五
- 新手入门--输入格式六
- 新手入门——输入格式一
- 新手入门--输出格式七
- 新手入门--输出格式八
- VB新手入门之四
- Pomelo 新手入门(四)
- python新手入门(四)
- jquery新手入门教学(四)
- 全文检索----新手入门(四)
- ffmpeg分析系列之四(探测输入的格式)
- ffmpeg分析系列之四(探测输入的格式)
- ffmpeg分析系列之四(探测输入的格式)
- JavaScript示例四(输入框数字格式检测)
- EditText每四位自动添加空格或者横线(银行卡输入格式,验券格式)
- 编程挑战题目--倒水
- 语音识别系统之htk------孤立词识别(yesno)
- windows xp下安装nfs客户端,使得windows xp 与 ubuntu 可以通过nfs共享文件夹
- 【android,12】12.handler 与message机制更改界面信息
- winform 只能输入数字(小数)
- 新手入门--输入格式四
- 【android,13】13.避免anr(application no response)的操作
- jquery遍历json数组方法
- FPGA 和 ASIC 开发的区别
- acm-1-n之间能够被m整除的数的和
- SQL EXISTS学习笔记
- 5、app启动流程、AppDelegate.m分析、xib介绍-OC+UI
- linux kernel panic 调用过程
- 给HTML初学者的三十条最佳实践