标签:while msu inf code tor shu family ati 微软
public static int bin_Search(int array[],int key){
int mid,high,low=0;
high = array.length-1;
while(low<=high){
mid=(low+high)/2;
if(array[mid]==key){
return mid;
}
if(array[mid]>key){//在前半段查找
high = mid - 1;//mid已经找过一次了,所以跳过
}
if(array[mid]<key){//在后半段查找
low = mid + 1;//mid已经找过一次了,所以跳过
}
}
return -1;
}
标签:while msu inf code tor shu family ati 微软
原文地址:http://www.cnblogs.com/0427mybirthday/p/7710757.html