博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
HDOJ(HDU) 2162 Add ‘em(求和)
阅读量:4326 次
发布时间:2019-06-06

本文共 1084 字,大约阅读时间需要 3 分钟。

Problem Description

Write a program to determine the summation of several sets of integers.

Input

The input file will consist of up to 250 sets of integers, where each set contains at most 100 integers and the integer values will be between –16000 and + 16000. Each set of numbers is started with the number of integers in the set, n. The next n input lines will each contain one integer of the set. You should stop processing when the size of the set, n, is<= 0.

Output

A single line of output should be generated for each set of integers. The line should have format shown below.

Sample Input

4
-1
3
1
1
2
19
17
5
-645
952
-1488
-5456
-9342
-1

Sample Output

Sum of #1 is 4
Sum of #2 is 36
Sum of #3 is -15979

简单题,就是求和。

import java.util.Scanner;public class Main{    public static void main(String[] args) {        Scanner sc = new Scanner(System.in);        int t=0;        while(sc.hasNext()){            int n =sc.nextInt();            if(n==-1){                break;            }            long  sum=0;            for(int i=0;i

转载于:https://www.cnblogs.com/webmen/p/5739220.html

你可能感兴趣的文章
PHP Curl发送数据
查看>>
HTTP协议
查看>>
CentOS7 重置root密码
查看>>
Centos安装Python3
查看>>
PHP批量插入
查看>>
laravel连接sql server 2008
查看>>
Laravel框架学习笔记之任务调度(定时任务)
查看>>
Ubuntu菜鸟入门(五)—— 一些编程相关工具
查看>>
valgrind检测linux程序内存泄露
查看>>
Hadoop以及组件介绍
查看>>
1020 Tree Traversals (25)(25 point(s))
查看>>
第一次作业
查看>>
“==”运算符与equals()
查看>>
单工、半双工和全双工的定义
查看>>
Hdu【线段树】基础题.cpp
查看>>
时钟系统
查看>>
BiTree
查看>>
5个基于HTML5的加载动画推荐
查看>>
水平权限漏洞的修复方案
查看>>
静态链接与动态链接的区别
查看>>