快速排序问题解决不了
#define SIZE 100#include <stdio.h>
#include <malloc.h>
typedef struct{
int key;
int nexi;
}SLNode;
typedef struct{
SLNode r[SIZE];
int length;
struct SqList *next;
}SqList ,*LinkList;
LinkList CreateList_L(LinkList&L,int n){
int i;
LinkList p;
L=(LinkList)malloc(sizeof(SqList));
L->next=NULL;
for(i=n;i>0;--i){
p=(LinkList)malloc(sizeof(SqList));
p->next=null;
p->data=getchar();
p->next=L->next;
L->next=p;
}
return L;
}
int Partition(SqList &L, int low, int high){
int pivotkey;
L.r[0] = L.r[low];
pivotkey = L.r[low].key;
while (low<high) {
while (low<high && L.r[high].key>=pivotkey)
--high;
L.r[low] = L.r[high];
while (low<high && L.r[low].key<=pivotkey)
++low;
L.r[high] = L.r[low];
}
L.r[low] = L.r[0];
return low;
}
void QSort(SqList &L, int low, int high)
{ int pivotloc;
if (low < high)
{
pivotloc = Partition(L, low, high);
QSort(L, low, pivotloc-1);
QSort(L, pivotloc+1, high);
}
}
main(){
LinkList L;
L=CreateList_L(L,10);
QSort(L, 1,10);
}