HDOJ 1094 A+B for Input-Output Practice (VI)
2015-10-22 16:05
681 查看
Problem Description
Your task is to calculate the sum of some integers.
Input
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.
Output
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.
Sample Input
4 1 2 3 4
5 1 2 3 4 5
Sample Output
10
15
Your task is to calculate the sum of some integers.
Input
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.
Output
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.
Sample Input
4 1 2 3 4
5 1 2 3 4 5
Sample Output
10
15
import java.util.*; class Main{ public static void main(String args[]){ Scanner sc = new Scanner(System.in); while(sc.hasNext()){ int m=sc.nextInt(); int sum=0; for(int i=0;i<m;i++){ int a= sc.nextInt(); sum+=a; } System.out.println(sum); } } }
相关文章推荐
- HDOJ 1093 A+B for Input-Output Practice (V)
- HDOJ 1092 A+B for Input-Output Practice (IV)
- HDOJ 1091 A+B for Input-Output Practice (III)
- HDOJ 1090 A+B for Input-Output Practice (II)
- HDOJ 1089 A+B for Input-Output Practice (I)
- Unix Network Programming(5)---SCTP
- 使用PHPmailer 发送邮件,使用QQ smtp服务器
- 禁用Cookie时,PHP共享Session文件解决方案
- ubuntu 14 server vsftp login incorrect 530
- php debug with xdebug xampp phpexcelipse
- php get_magic_quotes_gpc()函数用法介绍
- PHP编程效率的20个要点
- 通过quartz定时任务完成对FTP服务器上文档的下载
- [perl]ftpsync
- 在 Servlet 中,如果 parameter 的值不存在, getParameter 的返回值
- getParameter乱码
- viewpager 实现tab-----(viewpager + fragmentpageradapter)
- php 笔记
- 七牛云存储之图片的上传【PHP】
- 使用sublime进行PHP开发经验分享