华为OD机试真题-字符串摘要-2024年OD统一考试(E卷)

时间:2024-10-16 13:30:04
华为OD机试真题-智能成绩表-2023年OD统一考试(C卷d卷e卷)

qinyudong17: public static void main(String[] args) { Scanner in = new Scanner(System.in); // 读取学生人数 n 和科目数量 m String[] input = in.nextLine().split(" "); int n = Integer.parseInt(input[0]); int m = Integer.parseInt(input[1]); String[] subjects = in.nextLine().split(" "); List<String> subjectList = Arrays.stream(subjects).collect(Collectors.toList()); List<Student> students = new ArrayList<>(); for (int i = 0; i < n; i++) { String[] temp = in.nextLine().split(" "); String name = temp[0]; List<Integer> scores = new ArrayList<>(m); scores.add(Integer.parseInt(temp[1])); scores.add(Integer.parseInt(temp[2])); Student st = new Student(name, scores); students.add(st); } // 读取用于排名的科目名称 String sortSubject = in.nextLine(); if (subjectList.contains(sortSubject)) { // 以指定科目排序(降序) int index = subje