将两个数组合并,去除重复元素,并将新的数组元素进行排序后打印出(先分别输入两个数组元素个数,紧接着输入元素)
输入样例:4 -2 0 3 8 3 1 3 5
输出样例 -201358
不重复有序:SortedSet (java.util)
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
while (scanner.hasNext()) {
int m = scanner.nextInt();
SortedSet<Integer> set = new TreeSet<>();
for (int i = 0; i < m; i++) {
set.add(scanner.nextInt());
}
int n = scanner.nextInt();
for (int i = 0; i < n; i++) {
set.add(scanner.nextInt());
}
for (Integer i : set) {
System.out.print(i);
}
}
scanner.close();
}
}