二分查找
int binarySearch(int *p,int find,int l,int h) { int mid; while(l<=h) { mid=(l+h)/2; if(find==p[mid]) { return mid; } else if(find>p[mid]) { l=mid+1; } else { h=mid-1; } } return -1; }
int binarySearch(int *p,int find,int l,int h) { int mid; while(l<=h) { mid=(l+h)/2; if(find==p[mid]) { return mid; } else if(find>p[mid]) { l=mid+1; } else { h=mid-1; } } return -1; }