#include<stdio.h>
int main()
{
int all[] = {1,2,3,4,5,6,7,8,9,10};
int k = 7;
int zs = sizeof(all)/sizeof(all[0]};
int left = 0;
int right = zs -1;
while(left<=right)
{
int mid = (right+left)/2;
if(all[mid]<k)
{
left = left+1;
}
else if(mid>k)
{
right = right-1;
}
else
{
printf("找到了,下标是:%d\n",mid);
break;
}
}
if(left>right)
{
printf("找不到“);
}
return 0;
}