Scanner scanner = new Scanner(System.in); while (scanner.hasNext()) { int n = scanner.nextInt(); int m = scanner.nextInt(); Map<Integer, Integer> map = new HashMap<>(); for (int i = 0; i < n+m; i++) { map.put(scanner.nextInt(),scanner.nextInt()); } List<Map.Entry<Integer, Integer>> list=new ArrayList<>(map.entrySet()); Collections.sort(list,new Comparator<Map.Entry<Integer, Integer>>() { public int compare(Map.Entry<Integer, Integer> o1, Map.Entry<Integer, Integer> o2) { return o1.getKey().compareTo(o2.getKey()); } }); list.forEach(x->System.out.println(x.getKey()+" "+x.getValue())); }
0.0分
2 人评分
IP判断 (C++代码)浏览:677 |
大神老白 (C语言代码)浏览:715 |
【回文数(二)】 (C语言代码)浏览:857 |
C语言程序设计教程(第三版)课后习题8.8 (C语言代码)浏览:601 |
简单的a+b (C语言代码)浏览:760 |
【绝对值排序】 (C语言代码)浏览:717 |
C语言程序设计教程(第三版)课后习题10.7 (C语言代码)浏览:969 |
C语言程序设计教程(第三版)课后习题1.5 (C++代码)浏览:759 |
【出圈】 (C语言代码)浏览:796 |
WU-输入输出格式练习 (C++代码)浏览:1082 |