import java.util.*; public class LANQIAO { // 树集合自带排序功能 public static Set<Integer> A = new TreeSet<>(); public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); int x ; // 直接往 A 中加入 n + m 个元素 for (int i = 0; i < n + m; i++) { x = sc.nextInt(); A.add(x);// 不会添加重复值 } // 用一个变量和 A.size()控制换行 int cnt = 0 ; for (Integer i : A) { if( cnt != A.size() - 1) System.out.print(i + " "); else System.out.println(i); } } }
蓝桥杯真题-
最新推荐文章于 2024-07-20 22:33:40 发布