数据结构C语言版之查找(折半选择快速等)

//查找:
#include
#include
#include
typedef struct{	
	int *elem;
	int length;
}SStable;
typedef struct SYlist{
	int num;
	int *Key;
	int *start;
}SYlist;
void CreatSearchlist(SStable &S)
{
	int i;
	printf("请输入表长:\n");
	scanf("%d",&S.length);
	S.elem=(int*)malloc((S.length)*sizeof(int));
	for(i=1;iS.elem[j+1])
			{
				temp=S.elem[j];
				S.elem[j]=S.elem[j+1];
				S.elem[j+1]=temp;
			}
		}
	}
	ShowSStable(S);
}
int Zbsearch(SStable S,int e)
{
	int mid,high=S.length-1,low=1;
	while(low<=high)
	{
		mid=(low+high)/2;
		if(S.elem[mid]==e)
			return mid;
		else if(S.elem[mid]sy.Key[i])
		i++;
	if(i>0 && i=sy.num-1)
	{
		for(j=sy.start[sy.num];j

转载于:https://www.cnblogs.com/zhuhengjie/p/5966923.html

你可能感兴趣的:(数据结构C语言版之查找(折半选择快速等))