#include<stdio.h>
int sreach(int x, int a[], int n)
{
int left = 0;
int right = n - 1;
while (left <= right)
{
int mid = (left + right) / 2;
if (a[mid] < x)
{
left = mid + 1;
}
else if (a[mid] == x)
{
return mid;
}
else
{
right = mid - 1;
}
}
return -1;
}
int main()
{
int arr[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
int num = 0;
int sz = sizeof(arr) / sizeof(arr[0]);
scanf("%d", &num);
int ret = sreach(num, arr, sz);
if (ret == -1)
{
printf("该数不存在\n");
}
else
{
printf("a[%d]\n", ret); //查找的数在数组中的位置
}
return 0;
}