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 人评分
C语言程序设计教程(第三版)课后习题10.1 (C语言代码)浏览:1435 |
数列排序 (C语言代码)浏览:828 |
C语言程序设计教程(第三版)课后习题8.3 (C语言代码)浏览:411 |
【数组的距离】 (C语言代码)浏览:728 |
大小写转换 (C语言代码)浏览:840 |
简单的a+b (C语言代码)浏览:681 |
2004年秋浙江省计算机等级考试二级C 编程题(2) (C语言代码)浏览:1327 |
C语言程序设计教程(第三版)课后习题10.1 (C语言代码)浏览:530 |
C二级辅导-求偶数和 (C语言代码)浏览:671 |
剔除相关数 (C语言代码)浏览:1084 |