#include<iostream>
using namespace std;
#define NIL 1000;
void main()
{  int BinarySearch(int *A,int begin,int end ,int elem);
 int A[8]={1,3,5,7,8,10,12,14};
 int index=BinarySearch(A,0,7,10);
 cout<<index<<endl;
 char f;
 cin>>f;
}
int BinarySearch(int *A,int begin,int end,int elem)
{
 int l=begin;
 int h=end;
 int mid=(l+h)/2;
 if(A[mid]==elem)
  return mid;
 else
 {
  if(A[mid]<elem)
  {
   l=mid;
   if(h-l>1)
    BinarySearch(A,l,h,elem);
   else
    return NIL;
  }
  else
  {
   h=mid;
   if(h-l>1)
    BinarySearch(A,l,h,elem);
   else
    return NIL;
  }
 }
}
 
                    
                     
                    
                 
                    
                 
 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号