快速排序与二分查找的组合 学习笔记

#include
const short LEN=100;
//二分查找算法
int erfen(int a[],int low,int high,int key)
{
int mid=low+(high-low)/2;
if(low>high)
return -1;
else
{
if(a[mid]==key)
return mid;
else if(a[mid]>key)
return erfen(a,low,mid-1,key);
else
return erfen(a,mid+1,high,key);
}

}

int zhongzhi(int a[],int low,int high)
{
int low_value;
low_value=a[low];
while(low {
while(low=low_value)
–high;

	a[low]=a[high];
	while(low

}

void kuaisu(int a[],int low,int high)
{
int mid;
if(low {
mid=zhongzhi(a,low,high);
kuaisu(a,low,mid-1);
kuaisu(a,mid+1,high);

}

}

int main(){
int i,a[LEN];
int n;
int panduan=-1;
printf(“请输入字符串长度,最大值不超过1000:\n”);
scanf("%d",&n);if(n

printf("请输入%d个字符串,字符串之间用空格隔开:\n",n);
for(i=0;i

}

你可能感兴趣的:(c语言,数据结构)