求助,找程序错误,二分法查找
#include <stdio.h> main() {int a[10]={12,23,26,27,54,60,68,75,82,96}; int x,b=0,c=0; int Binsch(int A[],int n,int k ,int *p,int *q); printf("\ninput a number\n"); scanf("%d",&x); Binsch(a,10,x,&b,&c); printf("%d,%d,%d",x,b,c ); } int Binsch(int A[],int n,int k,int *p,int *q ) {int low=0,high=n-1; int mid; while(low<=high) {(int) mid=(low+high)/2; if(k==A[mid]) {*p= mid ; *q=i; } else if (k<A[mid]) high=mid-1; else low=mid+1; } return -1 ;
}