z***e 发帖数: 209 | 1 用个threshold判断一下,如果有很多冗余.
if(nArrSize>1000*nArr[nArrSize-1])
{
int* BS(int* nArr, int beg, int end)
{
int midup=midlow=reserveup=reservelow=0;
while(beg<=end)
{
reserveup = beg;
midup = (beg+end)/2;
if(num==nArr[midup]) beg=midup+1;
else break;
}
while(beg>=end)
{
reservelow = end;
midup = (beg+end)/2;
if(num==nArr[midup]) end=midup-1;
else break;
}
int* pInt = new int[2];
pInt[0]=reserveup;
pInt[1]=reservel... 阅读全帖 |
|