[求助]帮忙看一下这道程序题啊。。
#define m 5 main() {int i,j; int c; int a[m]; printf("input some numer\n"); for(i=1;i<=m;i++) scanf("%d",&a[i]); printf("input one number\n"); scanf("%d",&j); c=search(a,j); printf("%d",c); }
search(int a[],int k) {int low,mid,high; int n=1; low=0; high=m-1; while(low<=high) {mid=(low+high)/2; if(k==a[mid]) return n; else if(k>a[mid]) {low=mid+1;n++;} else {high=mid-1;n++;} } return -1; }