-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
48 lines (40 loc) · 1.26 KB
/
Main.java
File metadata and controls
48 lines (40 loc) · 1.26 KB
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
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer(br.readLine());
String A = st.nextToken();
String B = st.nextToken();
int x = -1, y = -1;
for(int i=0; i<A.length(); i++){
for(int j=0; j<B.length(); j++){
if(A.charAt(i) == B.charAt(j)) {
x = i;
y = j;
break;
}
}
if(x != -1 || y != -1) break;
}
Character[][] ans = new Character[B.length()][A.length()];
for(Character[] arr : ans){
Arrays.fill(arr, '.');
}
for(int i=0; i<A.length(); i++){
ans[y][i] = A.charAt(i);
}
for(int j=0; j<B.length(); j++){
ans[j][x] = B.charAt(j);
}
for(Character[] arr : ans){
for(Character ch : arr) {
System.out.print(ch);
}
System.out.println();
}
}
}