#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<string.h>
int main()
{
int k;
int a[] = { 1,2,3,4,5,6,7,8,9,10 };
int sz = sizeof(a) / sizeof(a[0]);// 计算元素个数
int left = 0;//左下标
int right = sz - 1;//右下标
scanf("%d", &k);
while (left<=right)
{
int mid = (left + right) / 2;
if (a[mid] > k)
{
right = mid - 1;
}
else if (a[mid] < k)
{
left = mid + 1;
}
else
{
printf("下标是:%d\n", mid);
break;
}
}
if (left > right)
{
printf("找不到此数\n");
}
return 0;
}