#include <stdio.h>
int binary_serach(int *buf,int x, int n)
{
int low,high,mid;
low=0;
high=n-1;
while(low<=high)
{
mid=(low+high)/2;
if(x>buf[mid])
high=mid-1;
else if(x<buf[mid])
low=mid+1;
else return mid;
}
return -1;
}
int main()
{
int buf[20];
int i,n,x,j;
printf("input the total of num:\n");
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d",&(buf[i]));
}
printf("input the num that you find:\n");
scanf("%d",&x);
j=binary_serach(buf,x,n);
if(j<0)printf("the num is not exist\n");
else printf("the %d num in the buf\n",j+1);
}