所编写的程序如下所示:
int* find(int* beg, int n, int target){
int* end = beg + n;
int* mid = beg + n/2;
while(beg <= end){
if(*mid < target){
beg = mid;
}
if(*mid > target){
end = mid;
}
if(*mid == target)
return mid;
mid = beg + (end - beg)/2;
}
return NULL;
}