```int main(void)
{
int n, x;
scanf("%d", &n);
for(int i = 0; i < n; i++)
{
scanf("%d", &a[i]);
}
sort(a, a+n);
scanf("%d", &x);
int l = 0, h = n-1;
while(l <= h)
{
int mid = (l + h) / 2;
if(a[mid] == x)
{
printf("find\n");
return 0;
}
if(a[mid] > x)
{
h = mid - 1;
}
else
{
l = mid + 1;
}
}
printf("not find\n");

return 0;
} ```

```int find1(int a[], int n, int x)  //二分查找需对已经有序的数列使用，数组a中的元素按升序排列
{
int low = 0, high = n - 1;
while (low <= high)
{
int mid = (low + high) / 2;
if (a[mid] < x)  //x > a[mid]
{
low = mid + 1;
}
else
{
high = mid - 1;
}
}
if (low == n)
{
printf("数组中的数均小于%d，不存在大于等于%d的数\n", x, x);
return 0;
}
else
{
return a[low];  //为什么返回a[low]，因为最终low下标一定比high下标大1，low是下标
}
}
int find2(int a[], int n, int x)  //二分查找需对已经有序的数列使用，数组a中的元素按升序排列
{
int low = 0, high = n - 1;
while (low <= high)
{
int mid = (low + high) / 2;
if (a[mid] < x)  //x > a[mid]
{
low = mid + 1;
}
else
{
high = mid - 1;
}
}
if (high + 1 == n)
{
printf("数组中的数均小于%d，不存在大于等于%d的数\n", x, x);
return 0;
}
else
{
return a[high + 1];  //返回a[high+1]，high+1是下标
}
}```