#include<iostream>
using namespace std;
int BinarySearch(int A[],int n,int find)
{
int low,upper,mid;
low = 0;upper = n-1;
while(upper>=low)
{
mid = low + (upper - low)/2;
//这里不直接用(low+upper)/2,避免upper+low出现溢出,因为实际low和upper的值可能很大,相加可能超出类型表示的范围。
if(find<A[mid])
upper = mid - 1;
else if(find>A[mid])
low = mid + 1;
else
return mid;
}
return -1;//未找到
}
int main()
{
int a[10],find;
cin>>find;
for(int i = 0;i < 10;i++)
cin>>a[i];//输入一个递增序列
i=BinarySearch(a,10,find);
if(i>=0)
cout<<"a["<<i<<"]="<<find<<endl;
else
cout<<"Not find"<<endl;
return 0;
}