int binarySearch(int A[], int left, int right, int x) {
int mid;
while(left < right) {
mid = (left + right) / 2;
if(需要成立的条件)
right = mid;
else {
left = mid + 1;
}
}
return left;
}
网友评论