二分查找
int binary_search(int array[], int n, intvalue)
{
int left=0,right=n-1;
while(left<=right)//防溢出,移位-高效。
{
int middle = left+ ((right-left)>>1);
if(array[middle]>value) right = middle - 1;
else if(array[middle] < value ) left = middle + 1;
else returnmiddle;
}
return -1;
}