请高手看看这个折半查找是否正确,请解释下,顺便来组测试数据!!
#include<stdio.h>main()
{ int a[10]={1,2,3,4,5,6,7,8,9,10};
int low=1,high=10;
int mid,i;
int find=0;
printf("输入一位正整:\n");
for(i=0;i<10;i++)
scanf("%5d",&a[i]);
printf("输入要查找的数:\n");
while(high>=low&&find==0)
{ mid=(high+low)/2;
if(10==a[mid])
{ find=1;break;
}
else if(10<a[mid])
high=mid-1;
else
low=mid+1;
}
if(find==0)
printf("not found:\n");
else
printf("pos is:%d\n");
system("pause") ;
}