int s(int l,int r,int k)//二分查找 76 { 77 int mid; 78 while(l<=r) 79 { 80 mid=(l+r)>>1; 81 if(k<x[mid]) r=mid-1; 82 else if(k>x[mid]) l=mid+1; 83 else return mid; 84 } 85 return -1; 86 }
int s(int l,int r,int k)//二分查找 76 { 77 int mid; 78 while(l<=r) 79 { 80 mid=(l+r)>>1; 81 if(k<x[mid]) r=mid-1; 82 else if(k>x[mid]) l=mid+1; 83 else return mid; 84 } 85 return -1; 86 }