给定一组从小到大排好序的数(互不相同)
采用二分搜索方法找到给定数的位置
#include <bits/stdc++.h>
using namespace std;
int main()
{
const int SIZE = 100;
int n,f,i,left,right,middle,a[SIZE];
cin>>n>>f;
for(int i=1;i<=n;i++)
cin>>a[i];
left=1;
right=n;
do
{
_____(1)_______
if(f<=a[middle])
right=____(2)_____;
else
left=_____(3)_____;
}while(left<right);
cout<<left<<endl;
}