#includeusing namespace std; int findx(int *xx,int x,int n) { //assert(xx); int l=0;int r=n; int mid=r/2; if(xx[l]==x) return l; if(xx[mid]==x)return mid; if(xx[r]==x) return r; if(xx[l] xx[r])l=0;r=mid; } while(l<=r) { mid=(l+r)/2; if(x==xx[mid]) return mid; else if(x xx[mid]) l =mid+1; } return -1; } int main() { int xx[]={21,22,33,44,45,2,4,6,8,10}; cout<
文章题目:小代码二分查找之部分有序
分享路径:http://chengdu.cdxwcx.cn/article/jecood.html