求检查下面的代码,折半查找的问题
#include<stdio.h>void main()
{
int num[15]={12,13,14,15,16,17,18,19,20,21,22,23,24,25,26};
int n,min=0,max=14,mid,temp;
scanf("%d",&n);
mid=(max+min)/2+1;
while(min<=max)
{
if(num[max]==n)
{
temp=max;
break;
}
else if(num[min]==n)
{
temp=min;
break;
}
else if(num[mid]==n)
{
temp=mid;
break;
}
else if(num[mid]>n)
{
max=mid-1;
break;
}
else if(num[mid]<n)
{
min=mid+1;
break;
}
}
printf("%d\n",temp+1);
}