#define LIST_INIT_SIZE 10
#define LIST_INCREMENT 2
struct SqList
{
ElemType *elem; //存储空间的基地址
int length;
int listsize; //当前分配的存储容量
};
//初始化
//构建空的线性表
void InitList(SqList &L){
L.elem=(ElemType*)malloc(LIST_INIT_SIZE*sizeof(ElemType));
if(!L.elem)
exit(OVERFLOW);
L.length=0;
L.listsize=LIST_INIT_SIZE;
}
//销毁
void DestroyList(SqList &L){
free(L.elem);
L.elem=NULL;
L.length=0;
L.listsize=0;
}
复习(数据结构):线性表 : C:动态分配内存
最新推荐文章于 2024-06-01 15:19:52 发布