折半查找
int BinarySearch(int len,int* arr,int x)
{
assert(arr);
int begin = arr[0];
int end = len;
while (begin < end)
{
int mid = ((end - begin) >> 2) + begin;
if (arr[mid] < x)
{
begin = mid + 1;
}
else if (arr[mid]>x)
{
end = mid - 1;
}
else
{
return mid;
}
return -1;
}
}