折半法查数,,两个错误,,大家帮我看看哪里错了
int binsearch(int x,int v[],int n) { int low,high,mid; low=0; high=n-1; mid=(low+high)/2; while(low<=high) { if(x<v[mid]) high=mid-1; else if(x>v[mid]) low=mid+1; else return mid; } return -1;
main() { int y, a[10]={1,2,3,4,5,6,7,8,9,10}; y=binsearch(10,a,10); printf("%d",y); }