-
Notifications
You must be signed in to change notification settings - Fork 0
/
synchronizinglists.java
54 lines (39 loc) · 1.5 KB
/
synchronizinglists.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
Integer setCount = -1;
List<Integer[][]> sets = new ArrayList<>();
while (setCount != 0) {
setCount = Integer.parseInt(scanner.nextLine());
Integer[] set1 = new Integer[setCount];
Integer[] set2 = new Integer[setCount];
Integer[][] set = new Integer[2][setCount];
for (int i = 0; i < setCount; i++) {
set1[i] = Integer.parseInt(scanner.nextLine());
}
for (int i = 0; i < setCount; i++) {
set2[i] = Integer.parseInt(scanner.nextLine());
}
set[0] = set1;
set[1] = set2;
sets.add(set);
}
Integer count = 0;
for (Integer[][] set : sets) {
if (count > 0 && count != sets.size()) {
System.out.println(" ");
}
count += 1;
List<Integer> set1 = Arrays.asList(set[0].clone());
List<Integer> set2 = Arrays.asList(set[1].clone());
Collections.sort(set1);
Collections.sort(set2);
for (int i = 0; i < set1.size(); i++) {
Integer toFind = Arrays.asList(set[0]).get(i);
Integer index = set1.indexOf(toFind);
System.out.println(set2.get(index));
}
}
}
}