java解法:用TreeSet就可以搞定
import java.util.*; public class Main{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); while(sc.hasNext()){ TreeSet<Integer> ts = new TreeSet<>(); int n1 = sc.nextInt(); for(int i=0; i<n1; i++){ ts.add(sc.nextInt()); } int n2 = sc.nextInt(); for(int i=0; i<n2; i++){ ts.add(sc.nextInt()); } for(int a:ts){ System.out.print(a); } System.out.println(); } } }