import java.util.*; public class Main { public static void main(String[] args) { Scanner reader = new Scanner(System.in); List<Student> students = new ArrayList<>(); while (reader.hasNextLine()) { String line = reader.nextLine().trim(); if ("end".equals(line)) { break; } else { String[] infos = line.split("\\s+"); Student student = new Student(infos[0], infos[1], Integer.parseInt(infos[2]), Integer.parseInt(infos[3])); students.add(student); } } Collections.sort(students, (a, b) -> { int abSum = a.math + a.physic; int bbSum = b.math + b.physic; if (abSum != bbSum) { return bbSum - abSum; } else { return students.indexOf(a) - students.indexOf(b); } });
7-1 容器-ArrayList-排序分数 100作者 蔡轲单位 南昌航空大学题目描述编辑输入多个学生的成绩信息,包括:学号、姓名、数学成绩、物理成绩。学号是每个学生的唯一识别号,
最新推荐文章于 2024-11-25 19:41:01 发布