蓝桥网试题 java 基础练习 数列特征

-----------------------------------

Collections.sort(list);是个好东西

但是要学会排列

然后你才能浪

-----------------------------------

算法

 1 import java.util.*;
 2 public class Main {
 3     public static void main(String[] args) {
 4         Scanner sc = new Scanner(System.in);
 5         ArrayList<Integer> list = new ArrayList<Integer>();
 6         int n = sc.nextInt();
 7         for(int i=0;i<n;i++)
 8             list.add(sc.nextInt());
 9         Collections.sort(list);
10         System.out.println(list.get(list.size()-1));
11         System.out.println(list.get(0));
12         int x = 0;
13         for(int i:list)
14             x += i;
15         System.out.println(x);
16     }
17 }

 

 

 

 

 

 

原文地址:https://www.cnblogs.com/loveluking/p/6067592.html