二分查找代码

 1 int bsearchWithoutRecursion(int array[],int low,int high,int target)
 2 {
 3     while(low<=high)
 4         {
 5             int mid=(low+high)/2;
 6             if(array[mid]>target)
 7                 high=mid-1;
 8             else if(array[mid]<target)
 9             low=mid+1;
10             else
11                 return mid;
12         }
13     return-1;
14 }

 扩展:

http://www.cnblogs.com/luoxn28/p/5767571.html

http://blog.csdn.net/yefengzhichen/article/details/52372407

http://www.ahathinking.com/archives/179.html

http://blog.csdn.net/clockwiser/article/details/8019069

http://www.cnblogs.com/huashanqingzhu/p/6882821.html

原文地址:https://www.cnblogs.com/huashanqingzhu/p/6882662.html