home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The C Users' Group Library 1994 August
/
wc-cdrom-cusersgrouplibrary-1994-08.iso
/
listings
/
v_02_05
/
2n05064d
< prev
next >
Wrap
Text File
|
1991-03-27
|
375b
|
23 lines
int *binsearch(int x, const int v[], size_t n)
{
size_t low = 0;
size_t high = n;
int mid;
while (low < high)
{
mid = (low + high) / 2;
if (x < v[mid])
high = mid;
else if (x > v[mid])
low = mid + 1;
else
return &v[mid];
}
return 0;
};