void erfen(int a[],int low,int high,int N)
{
int cent;
while(low<=high)
{
cent=(low+high)/2;
if(a[cent]>N) //非递归实现方法
high=cent-1;
else if(a[cent]<N)
low=cent+1;
else
cout<<cent<<endl;
}
cout<<"not find\n"<<endl;
void erfen_digui(int a[],int low,int high,int N)
{
if(low>high)
{
cout<<"not find"<<endl;
}
int cent=(low+high)/2;
if(a[cent]==N)
cout<<cent<<endl;
else
{
if(a[cent]>N)
erfen_digui(a,low,cent-1,N); //递归实现方法
else
erfen_digui(a,cent+1,high,N);
}
}