-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJ03009
49 lines (45 loc) · 1.45 KB
/
J03009
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
package test;
import java.util.*;
public class J03009 {
public static void DevideString(String s, Vector<String> a) {
String x = "";
s = s.toLowerCase() + " ";
for (int i = 0; i < s.length(); i++) {
if (s.charAt(i) == ' ') {
if (x != "") {
a.add(x);
x = "";
}
} else {
x += s.charAt(i);
}
}
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
sc.nextLine();
while (t-- > 0) {
String s1 = sc.nextLine();
String s2 = sc.nextLine();
Vector<String> v1 = new Vector<String>();
Vector<String> v2 = new Vector<String>();
Vector<String> v = new Vector<String>();
DevideString(s1, v1);
DevideString(s2, v2);
Map<String, Integer> m = new HashMap<String, Integer>();
for (int i = 0; i < v2.size(); i++)
m.put(v2.get(i), 1);
for (int i = 0; i < v1.size(); i++) {
if (m.get(v1.get(i)) == null) {
v.add(v1.get(i));
m.put(v1.get(i), 1);
}
}
Collections.sort(v);
for (int i = 0; i < v.size(); i++)
System.out.print(v.get(i) + " ");
System.out.println();
}
}
}