-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest14.java
More file actions
103 lines (73 loc) · 1.04 KB
/
test14.java
File metadata and controls
103 lines (73 loc) · 1.04 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
class LinearSearch {
public static void main(String[] a) {
System.out.println(new LS().Start(10));
}}
class LS{
int[] number;
int size;
public int Start(int sz){
int aux01;
int aux02;
aux01 = this.Init(sz);
aux02 = this.Print();
System.out.println(9999);
System.out.println(this.Search(8));
System.out.println(this.Search(12));
System.out.println(this.Search(17));
System.out.println(this.Search(50));
return 55;
}
public int Print(){
int j;
j = 1;
while(j<(size))
{System.out.println(number[j]);
j = j+1;
}
return 0;
}
public int Search(int num){
int j;
boolean ls01;
int ifound;
int aux01;
int aux02;
int nt;
j = 1;
ls01 = false;
ifound = 0;
while(j<(size))
{aux01 = number[j];
aux02 = num+1;
if(aux01<num)
nt = 0;
else
if(!(aux01<aux02))
nt = 0;
else
{ls01 = true;
ifound = 1;
j = size;
}
j = j+1;
}
return ifound;
}
public int Init(int sz){
int j;
int k;
int aux01;
int aux02;
size = sz;
number = new int[sz];
j = 1;
k = size+1;
while(j<(size))
{aux01 = 2*j;
aux02 = k-3;
number[j] = aux01+aux02;
j = j+1;
k = k-1;
}
return 0;
}}