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 人评分
wu-理财计划 (C++代码)浏览:841 |
2005年春浙江省计算机等级考试二级C 编程题(1) (C语言代码)浏览:607 |
C语言程序设计教程(第三版)课后习题6.2 (C语言代码)浏览:694 |
C语言程序设计教程(第三版)课后习题5.4 (C语言代码)浏览:566 |
模拟计算器 (C++代码)浏览:820 |
printf基础练习2 (C语言代码)浏览:515 |
C语言训练-亲密数 (C语言描述,反正怎么都能对)浏览:2174 |
Pascal三角 (C语言代码)浏览:664 |
单词个数统计 (C语言代码)浏览:1015 |
简单的a+b (C语言代码)浏览:579 |