1. 程式人生 > 其它 >C++基礎之mutable

C++基礎之mutable

技術標籤:個人學習分享演算法

//二分查詢法
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; }``` 待續。。。