蓝桥杯- 基础练习: 数列特征

蓝桥杯- 基础练习: 数列特征_第1张图片

蓝桥杯- 基础练习: 数列特征_第2张图片

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        long min = 0;
        long max = 0;
        long add = 0;
        Scanner scanner = new Scanner(System.in);
        int size = scanner.nextInt();
        long ints[] = new long[size];
        for (int i = 0; i < size; i++) {
            ints[i] = scanner.nextInt();
        }
        min = max = ints[0];
        for (int i = 0; i < ints.length; i++) {
            add += ints[i];
            if (max<ints[i]) {
                max = ints[i];
            }
            if (min>ints[i]) {
                min = ints[i];
            }
        }
        System.out.println(max);
        System.out.println(min);
        System.out.println(add);
    }
}

 

转载于:https://www.cnblogs.com/wzqjy/p/8284265.html

你可能感兴趣的:(java)