线性表的顺序指的是用一组地址连续的存储单元依次存储线性表的数据元素。
线性表动态分配内存
#define LIST_INIT_SIZE 100 // 线性表存储空间的初始分配量
#define LISTINCREMENT 10 // 线性表存储空间的分配增量
typedef struct {
ElemType *elem; // 存储空间基址
int length; // 长度
int listsize; // 当前分配的存储容量
} SqList
Status InitListSq(SqList &L) {
L.elem = (ElemType *)malloc(LIST_INIT_SIZE * sizeof(ElemType));
if (!L.elem) exit(OVERFLOW);
L.length = 0;
L.listsize = LIST_INIT_SIZE;
}
// 线性单链接存储结构
typedef struct LNode {
ElemType data;
struct LNode * next;
}LNode, * LinkList