📅  最后修改于: 2022-03-11 14:44:45.123000             🧑  作者: Mango
int binarySearch(vector& arr, int p, int r, int num) {
while (p <= r) {
int mid = (p + r)/2;
if (arr[mid] == num) return mid;
else if (arr[mid] > num) r = mid-1;
else p = mid+1;
}
return -1;
}