int zheban(int i, int j, int data[], int base)
{
int k;
if(base>data[j]||base<data[i])
return 0;
k = (i + j) / 2;
if(data[k] == base)
return k;
else if(base < data[k])
{
j=k;
}
else if(base > data[k])
{
i=k;
}
if((j-i)==0||(j-i)==1)
{
if(data[k]!=base)
return 0;
else
return k;
}
return zheban(i,j,data,base);
}
void qijiu(void)
{
int a[15]={1,4,9,13,21,34,55,89,144,233,377,570,671,703,812};
int i,j,n;
for(i=0;i<15;i++)
printf("%4d",a[i]);
printf("/n请输入要查找的数:");
scanf("%d",&n);
i=0;
j=14;
if(zheban(i,j,a,n))
printf("你要查找的数在数组的第%d个位置/n",zheban(i,j,a,n)+1);
else
printf("数组里没有你要查找的数/n");
}