/*递归二分查找*/
#include
int select(int a[],int low,int high,int key);
void main(){
int a[10]={11,21,31,41,51,61,71,81,91,101};
int low=0,high=9;
int key;
printf("请输入要查找的数:");
scanf("%d",&key);
int num=select(a,low,high,key); //定义num接收select函数的返回值
if(num==-1){
printf("查找失败!");
}else{
printf("该数是第 %d 个数。",num);
}
}
//low:数组第一个位置 high:最高 key:要查找的数
int select(int a[],int low,int high,int key){
if(low<=high){
int mid=(low+high)/2;
if(a[mid]==key){
return mid;
}else if(a[mid]