小代码二分查找之部分有序
#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://scjbc.cn/article/jecood.html