solution.java 687 字节
Newer Older
每日一练社区's avatar
每日一练社区 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

//成绩分析(利用集合) 
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        ArrayList<Integer> list = new ArrayList<>();
        int n = scan.nextInt();
        double sum = 0;
        for (int i = 0; i < n; i++) {
            list.add(scan.nextInt());
            sum = sum + list.get(i);
        }
        Collections.sort(list);
        System.out.println(Collections.max(list));
        System.out.println(Collections.min(list));
        System.out.println(String.format("%.2f", sum / n));
        scan.close();
    }
}