#include <iostream>
using namespace std;
int main()
{
int i,n,a[20],find,num=0;
cout<<“输入数组大小:”<<endl;
cin>>n;
cout<<“输入数组元素:”<<endl;
for(i=0;i<n;i++)
{
cin>>a[i];
}
cout<<“输入要查找的数:”<<endl;
cin>>find;
int left,right,mid;
left=0;
right=n-1;
mid=(left+right)/2;
for(i=0;i<n;i++)
{
if(a[mid]>find)
{
left=mid+1;
}
if(a[mid]<find)
{
right=mid-1;
}
if(a[i]==find)
{
cout<<find<<“为:a[“<<i<<“];”<<endl;
num++;
}
}
if(num==0){cout<<“未找到”<<endl;}
return 0;
}