#include<iostream>
using namespace std;
int main()
{
int a[10] = {10,20,35,45,52,54,64,68,74,84}; //必须为有序数组
int fist = 0, end = 9, mid = (fist + end) / 2;
int b;
cout << "输入目标数:" << endl;
cin >> b;
do
{
if (b > a[mid])
{
fist = mid + 1;
mid = (end + fist) / 2;
}
else if (b < a[mid])
{
end = mid - 1;
mid = (fist + end) / 2;
}
} while (b != a[mid]); //执行条件
cout << "找到了,位置是:" << mid << endl;
return 0;
}