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

本文共 1034 字,大约阅读时间需要 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

转载地址:http://ffhpo.baihongyu.com/

你可能感兴趣的文章
pyqt5 动画学习(二) 改变控件颜色
查看>>
codevs 3981 动态最大子段和
查看>>
Codeforces 221 D. Little Elephant and Array
查看>>
spring boot学习(7) SpringBoot 之表单验证
查看>>
对Oracle数据库的相关练习
查看>>
《稀缺》读后感
查看>>
GNU Radio在SDR领域的应用
查看>>
POJ3928 Ping pong
查看>>
洛谷P2024 食物链
查看>>
linux系统开机流程详解
查看>>
《计算机图形学3D》
查看>>
CSU - 2059 Water Problem
查看>>
20131109
查看>>
数据结构与算法面试题80道(21)
查看>>
redis模块
查看>>
lua学习之table类型
查看>>
Regular expression
查看>>
Codeforces Round #368 DIV2 C.
查看>>
html5在canvas中插入图片
查看>>
门诊住院流程图
查看>>