标签:
bool Bin_Search(const int *pre, int low, int high, const int key) { while(low < high) //注意 { int mid = low + ((high-low)>>1); if(pre[mid] == key) return true; else if(pre[mid] < key) low = mid + 1; else high = mid; //注意 } return false; } bool Bin_Search(const int *pre, int low, int high, const int key) { high--; while(low <= high) { int mid = low + ((high-low)>>1); if(pre[mid] == key) return true; else if(pre[mid] < key) low = mid + 1; else high = mid + 1; } return false; }
版权声明:感觉我写的还算不错的的话希望你能够动动你的鼠标和键盘为我点上一个赞或是为我奉献上一个评论,在下感激不尽!_______________________________________________________欢迎转载,希望在你转载的同时,添加原文地址,谢谢配合
标签:
原文地址:http://blog.csdn.net/u011225629/article/details/48109653