-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIndexarray.java
More file actions
58 lines (55 loc) · 1.01 KB
/
Copy pathIndexarray.java
File metadata and controls
58 lines (55 loc) · 1.01 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
import java.util.*;
public class Indexarray
{
int arr[];
Indexarray()
{
arr=new int[100];
}
void fillarr()
{
Scanner sc=new Scanner(System.in);
for(int i=0;i<100;i++)
{
System.out.println("Enter Employee Code");
arr[i]=sc.nextInt();
}
}
void sortarr()
{
int t,p;
for(int i=0;i<99;i++)
{
p=i;
for(int j=i+1;j<100;j++)
{
if(arr[p]>arr[j])
p=j;
}
t=arr[i];
arr[i]=arr[p];
arr[p]=t;
}
}
int binarysearch(int a[],int c)
{
int u=100,l=0;
while(l<u)
{
int p=(u+l)/2;
if(c<a[p])
{
u=p;
l+=1;
}
else if(c==a[p])
return 1;
else
{
l=p;
u-=1;
}
}
return 0;
}
}