int bin_search(int a[],int len,int key)
{
int low=0;
int high=len-1;
while(low<=high) //若为low<high; e.g.1,2,3,4,5 假设search 5 ,终于 low==high=4(指的是下标。从0開始。而循环
//体 不运行。
{
int mid=low+(high-low)/2;
if(a[mid]==key) return mid;
else
if(a[mid]<key)
low=mid+1;
else
high=mid-1;
}
if(low>high)
return -1;
}