//有序数组二分查找
int bsearch(int array[], int left, int right, int target)
{
while (left <= right)
{
int mid = (left+right)/2;
if (array[mid] == target) return mid;
else if (array[mid] > target) right=mid-1;
else left=mid +1;
}
return -1;
}
posted on 2006-09-11 05:10
hzb 阅读(1173)
评论(2) 编辑 收藏 引用