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

蓝桥网试题 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 }

 

 

 

 

 

 

 

相关文章:

  • 2022-12-23
  • 2021-06-07
  • 2022-12-23
  • 2021-08-29
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-23
猜你喜欢
  • 2021-05-24
  • 2021-11-28
  • 2021-08-08
  • 2021-08-14
  • 2022-12-23
  • 2022-12-23
  • 2021-06-10
相关资源
相似解决方案