-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProblem51.java
45 lines (35 loc) · 1.15 KB
/
Problem51.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
package dimikOJ;
import java.util.Scanner;
public class Problem51 {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner input = new Scanner(System.in);
int T = input.nextInt();
while (T < 1) {
T = input.nextInt();
}
input.nextLine();
String[] inputs = new String[T];
for (int i = 0; i < T; i++) {
String temp = input.nextLine();
String[] tempArray = temp.trim().replaceAll("\\s{2,}", " ").split("\\s");
while (tempArray[0].length() > 128 || tempArray[0].length() < 1 || tempArray[1].length() > 128
|| tempArray[1].length() < 1) {
temp = input.nextLine();
tempArray = temp.trim().replaceAll("\\s{2,}", " ").split("\\s");
}
inputs[i] = temp.trim().replaceAll("\\s{2,}", " ");
}
input.close();
for (int i = 0; i < inputs.length; i++) {
String[] tempArray = inputs[i].split("\\s");
String main = tempArray[0];
String sub = tempArray[1];
if (main.contains(sub)) {
System.out.println(main.indexOf(sub));
} else {
System.out.println('"' + sub + '"' + " is not a valid substring of " + '"' + main + '"');
}
}
}
}