解题思路:
注意事项:
参考代码:
import java.util.*; import java.util.concurrent.atomic.AtomicInteger; public class Main { public static void main(String[] args){ Scanner cin = new Scanner(System.in); int n = cin.nextInt(); Map<Integer, List<Integer>> map = new HashMap<>(); map.put(1, new ArrayList<>()); map.put(2, new ArrayList<>()); map.put(3, new ArrayList<>()); map.put(4, new ArrayList<>()); map.put(5, new ArrayList<>()); for(int i = 0; i < n; i++){ int grade = cin.nextInt(); if (grade >= 0 && grade <=59){ map.get(5).add(grade); }else if(grade >= 60 && grade <=69){ map.get(4).add(grade); }else if(grade >= 70 && grade <=79){ map.get(3).add(grade); }else if(grade >= 80 && grade <=89){ map.get(2).add(grade); }else if(grade >= 90 && grade <=100){ map.get(1).add(grade); } } int max = -1; int count = 0; List<Integer> maxList = null; for(int k :map.keySet()){ count ++; int size = map.get(k).size(); System.out.print(size); System.out.print(" "); if(max < size){ max = size; maxList = map.get(k); } if(count == 5){ System.out.println(); } } System.out.println(max); assert maxList != null; maxList.sort((o1, o2) -> o2 - o1); maxList.forEach(e -> { System.out.print(e); System.out.print(" "); }); } }
0.0分
1 人评分
C语言考试练习题_保留字母 (C语言代码)浏览:561 |
C语言程序设计教程(第三版)课后习题9.3 (Java代码)浏览:956 |
母牛的故事 (C语言代码)浏览:435 |
C语言程序设计教程(第三版)课后习题1.5 (C++代码)浏览:755 |
WU-输出正反三角形 (C++代码)浏览:1018 |
2004年秋浙江省计算机等级考试二级C 编程题(2) (C语言代码)浏览:1327 |
1908题解浏览:633 |
C语言程序设计教程(第三版)课后习题5.7 (C语言代码)浏览:537 |
A+B for Input-Output Practice (VI) (C语言代码)浏览:552 |
Tom数 (C语言代码)浏览:725 |