C++基礎之mutable
阿新 • • 發佈:2020-12-16
//二分查詢法
bool Binary_search(int* list,int len , int item) {
int low = 0, high = len - 1;
int guess = 0;
while (low <= high) {
int mid = (high + low) / 2;
guess = list[mid];
if (item == guess) {
return true;
}
if (item < guess) {
high = mid - 1;
}
if (item > guess) {
low = mid + 1;
}
}
return false;
}```
待續。。。