顺序存储的线性表类型定义和顺序表的初始化。
#include <stdio.h>
#define INIT_SIZE 5
#define INCREMENT 2
typedef int ElemType;
typedef struct{
ElemType *elem;
int length;
int listsize;
}SqList;
int InitList_Sq(SqList *L)
{
L->elem=(ElemType*)malloc(INIT_SIZE*sizeof(ElemType));
if(!L->elem) return 0;
L->length=0;
L->listsize=INIT_SIZE;
return 1;
}
int main(void)
{
SqList L;
if(InitList_Sq(&L)==1)
printf("Initialization succeed %d\n",L.listsize);
}