int erfen(int *arr, int s, int n)
{
int r = s-1;
int l = 0;
while (l<=r) {
int mid = (r+l)/2;
if (n > arr[mid]) {
l = mid+1;
} else if (n < arr[mid]) {
r = mid-1;
}else{
return mid;
}
}
return -1;
}
二分查找算法
最新推荐文章于 2024-11-11 20:59:17 发布