#include <stdio.h>
#define N 10
/************found************/
void fun(int a[], int m)//根据主函数中“k=fun(a,m);”,知道函数fun应该是返回int型的函数,所以第一个标识下面定义的“void fun(int a[],int m)”应该改为“int fun(int a[],int m)”。
{int low=0,high=N-1,mid;
while(low<=high)
{mid=(low+high)/2;
if(m<a[mid])
high=mid-1;
/************found************/
else If(m > a[mid])//else If”当中“If”应当小写,
low=mid+1;
else return(mid);
}
return(-1);
}
main()
{int i,a[N]={-3,4,7,9,13,45,67,89,100,180 },k,m;
printf("a数组中的数据如下:");
for(i=0;i<N;i++) printf("%d ", a[i]);
printf("Enter m: "); scanf("%d",&m);
k=fun(a,m);
if(k>=0) printf("m=%d,index=%d\n",m,k);
else printf("Not be found!\n");
}