-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmaster.java
More file actions
89 lines (67 loc) · 1.53 KB
/
master.java
File metadata and controls
89 lines (67 loc) · 1.53 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import java.util.Scanner;
import java.io.*;
import java.lang.*;
class master {
public static void main(String[] args) throws IOException {
BufferedReader fileio;
fileio = new BufferedReader(new FileReader("pimillion.txt"));
String line = fileio.readLine();
int arr[] = new int[1000000];
int tmp = 0;
int i = 0;
int j = 0;
int con[] = new int[1000];
for(i=0 ; i<arr.length ; i++)
{
char ch = line.charAt(i);
arr[i] = Character.getNumericValue(ch);
}
Scanner scan = new Scanner(System.in);
System.out.println("Enter the name");
String name = scan.nextLine().toLowerCase();
System.out.println("The entered name is "+name);
int ptr = 0;
for(i=0;i<name.length();i++)
{
char ch = name.charAt(i);
tmp = (int)ch;
tmp = tmp-96;
if((tmp>=10)&&(tmp<=26))
{
con[ptr] = tmp/10;
con[ptr+1] = tmp%10;
ptr+=2;
}
else if (tmp<10) {
con[ptr] = tmp;
ptr++;
}
}
System.out.println("The numeric array is being printed\n");
for(i=0;i<ptr;i++)
System.out.println(" "+con[i]);
int counter = 0;
for(i=0;i<=(arr.length-con.length);i++)
{
counter = 0;
if(arr[i]==con[counter])
{
counter++;
for(j=i+1;j<(i+con.length);j++)
{
if(arr[j]==con[counter])
counter++;
}
}
if(counter==con.length)
{
System.out.println("The array is present in the position "+i);
break;
}
if(counter!=con.length)
{
System.out.println("The array is not present in the position " + i);
}
}
}
}