hdu 1094 A+B for Input-Output Practice (VI)
2015-08-31 09:05
701 查看
[align=left]Problem Description[/align]
Your task is to calculate the sum of some integers.
[align=left]Input[/align]
Input contains multiple test cases, and one case one line. Each case starts with an integer N, and then N integers follow in the same line.
[align=left]Output[/align]
For each test case you should output the sum of N integers in one line, and with one line of output for each line in input.
[align=left]Sample Input[/align]
4 1 2 3 4
5 1 2 3 4 5
[align=left]Sample Output[/align]
10
15
#include <stdio.h>
int main()
{
int i,n,m,t,sum;
while(scanf("%d",&n)!=EOF)
{
sum=0;
while(n--)
{
scanf("%d",&m);
sum+=m;
}
printf("%d\n",sum);
}
return 0;
}
Your task is to calculate the sum of some integers.
[align=left]Input[/align]
Input contains multiple test cases, and one case one line. Each case starts with an integer N, and then N integers follow in the same line.
[align=left]Output[/align]
For each test case you should output the sum of N integers in one line, and with one line of output for each line in input.
[align=left]Sample Input[/align]
4 1 2 3 4
5 1 2 3 4 5
[align=left]Sample Output[/align]
10
15
#include <stdio.h>
int main()
{
int i,n,m,t,sum;
while(scanf("%d",&n)!=EOF)
{
sum=0;
while(n--)
{
scanf("%d",&m);
sum+=m;
}
printf("%d\n",sum);
}
return 0;
}
相关文章推荐
- PHP中的strtotime()对于31日求上个月有问题
- ppptp安装脚本
- php正则表达式的基本语法
- php大力力 [039节] 修改一下后台项目,同时启用印象笔记,要做的事情todo列表,记录在印象笔记,速度快一些
- php防攻击方法
- PHP不仅仅是PHP
- PHP函数库(other)
- php中ajax跨域请求---小记
- PHP常用验证正则表达式
- 五种常见的 php设计模式
- PHP中error_reporting()用法详解
- php基础设计模式大全(注册树模式、工厂模式、单列模式)
- ECSHOP在PHP5.5及高版本上报错的解决方法
- 树莓派上vsftp的安装和配置
- PHP x86,x64,VC6,VC9,VC11,TS和NTS的选择
- Mac 安装phpmyadmin提示无法登陆 mysql服务器解决办法
- MVC模式的php框架 炼成记
- 流程控制语句if/switch
- 运算符的优先级
- 逻辑运算符