解题思路:
注意事项:
参考代码:
import java.util.Comparator; import java.util.Scanner; import java.util.TreeSet; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int m = sc.nextInt(); int n = sc.nextInt(); TreeSet<Student> set = new TreeSet<>(new Comparator<Student>() { @Override public int compare(Student o1, Student o2) { return o1.id - o2.id; } }); for (int i = 0; i < m + n; i++) { int id = sc.nextInt(); int score = sc.nextInt(); set.add(new Student(id, score)); } for (Student student : set) { System.out.println(student.id + " " + student.score); } sc.close(); } } class Student { Integer id; Integer score; public Student(Integer id, Integer score) { this.id = id; this.score = score; } }
0.0分
0 人评分
人见人爱A+B (C语言代码)浏览:866 |
回文数字 (C++代码)浏览:890 |
C语言训练-字符串正反连接 (C语言代码)浏览:726 |
C语言训练-求素数问题 (C语言代码)浏览:989 |
程序员的表白 (C语言代码)浏览:1574 |
C语言程序设计教程(第三版)课后习题7.1 (C语言代码)浏览:642 |
a+b浏览:452 |
C语言程序设计教程(第三版)课后习题5.7 (C语言代码)浏览:593 |
C语言程序设计教程(第三版)课后习题10.2 (C语言代码)浏览:560 |
老王赛马 (C++代码)浏览:973 |