题解 | HJ80#整型数组合并#
整型数组合并
https://www.nowcoder.com/practice/c4f11ea2c886429faf91decfaf6a310b
import java.util.*; // 注意类名必须为 Main, 不要有任何 package xxx 信息 public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); TreeSet<Integer> set = new TreeSet<>(); ArrayList<Integer> list = new ArrayList<>(); // 第一个数组 int i = scanner.nextInt(); for (int i1 = 0; i1 < i; i1++) { int i2 = scanner.nextInt(); set.add(i2); } //第2个数组 int i3 = scanner.nextInt(); for (int i4 = 0; i4 < i3; i4++) { int i5 = scanner.nextInt(); set.add(i5); } for (Integer integer : set) { list.add(integer); } Collections.sort(list); list.forEach(System.out::print); } }