二分查找的算法
二分查找的算法,谁有谁会救一下兄弟呀
int binary(int a[],int x,int n){
int low,mid,high;
low = 0;
high = n - 1;
while(low<=high){
mid = (low + high)/2;
if(x>a[mid])
low = mid + 1
else if(x<a[mid])
high = mid - 1;
else
return mid;
}
return notfound; //notfound 设为-1
}
}