可以执行,但不出结果,麻烦大家看哪有问题
#include "stdafx.h"
#include <iostream>
using namespace std;
#define MaxSize 50
typedef int Elemtype;
typedef struct
{
Elemtype date[MaxSize];
int length;
} SqList;
void CreateList(SqList *&L,Elemtype a[],int n)
{
int i;
for(i=0;i<n;i++)
L->date[i]=a[i];
L->length=n;
}
int ListLength(SqList *L){
return (L->length);}
void DispList(SqList *l){
int i;
if(ListEmpty(l)) return ;
for(i=0;i<l->length;i++)
cout<<l->date[i]<<" ";
}
void movel(SqList *&l){
int i=0,j=l->length-1;
Elemtype pivot=l->date[0];
Elemtype tmp;
while (i!=j){
while(i<j&&l->date[j]>pivot)
j--;
while(i<j&&l->date[i]<pivot)
i++;
if(i<=j)
{tmp=l->date[i];
l->date[i]=l->date[j];
l->date[j]=tmp;}
}
}
int main()
{
SqList *l;
int a[10]={3,5,6,1,4,2,7,9,8,0};
CreateList(l,a,10);
movel(l);
DispList(l);
return 0;
}
int main() 中 SqList *l没分配空间;