import java.util.Iterator; import java.util.Scanner; import java.util.Set; import java.util.TreeSet; public class CombineArray { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int first = scan.nextInt(); int []fArray = new int[first]; for (int i = 0; i < fArray.length; i++) { fArray[i] = scan.nextInt(); } int second = scan.nextInt(); int []sArray = new int[second]; for (int j = 0; j < sArray.length; j++) { sArray[j] = scan.nextInt(); } getCombineArray(fArray,sArray); } private static void getCombineArray(int[] fArray, int[] sArray) { Set<Integer> set = new TreeSet<Integer>(); for (int i = 0; i < fArray.length; i++) { set.add(fArray[i]); } for (int i = 0; i < sArray.length; i++) { set.add(sArray[i]); } Iterator<Integer> it = set.iterator(); while (it.hasNext()) { System.out.print(it.next()); } } }
版权声明:本文为博主原创文章,未经博主允许不得转载。
时间: 2024-10-13 16:13:30