二分法查找,有缺陷,帮忙改改啊。
#include"stdio.h"#define N 10
int main()
{
int number[N],i,x;
int high,low,mid;
for(i=1;i<N;i++)
scanf("%d",&number);
high=N-1;
low=0;
mid=(high+low)/2;
printf("Please input a number:\n");
scanf("%d",&x);
while(x!=a[mid]&&high-low!=1)
{
if(x>a[mid]) low=mid;
else high+mid;
mid=(high+low)/2;
}
if(x==a[mid]) printf("Position is %d",mid);
else printf("Unfind %d",x);
return 0;
}