#include<stdio.h>
#include<stdlib.h>
#define MaxSize 60
#define ElemType int
typedef struct {
ElemType data[MaxSize];
int length;
}SqList;
void CreateList_Sq(SqList *&L,ElemType a[],int n){//建立线性表
int i;
L = (SqList *)malloc(sizeof(SqList)); /*分配存放线性空间*/
for(i = 0;i < n;i++){
L -> data[i] = a[i];
}
L -> length = n; /*令线性表L的长度为n*/
}
int main(){
SqList * L;
int i;
ElemType a[] = {1,2,3,4,5};
CreateList_Sq(L,a,sizeof(a)/sizeof(int));
for(i = 0;i < 5;i++){
printf("%d
",L->data[i]);
}
return 0;
}