#include <stdio.h>
#include <stdlib.h>
#define TRUE 1
#define FALSE 0
#define OK 1
#define ERROR 0
#define INFEASIBLE -1
#define OVERFLOW -2
#define LIST_INIT_SIZE 100
#define LISTINCREMENT 10
typedef int Status;
typedef int ElemType;
typedef struct {
ElemType *elem;
int length;
int listsize;
}SqList;
//操作结果:构造一个空的线性表L
Status 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;
return OK;
}
Status ResizeList(SqList *L,int increment){
ElemType *newbase = (ElemType*)realloc(L->elem,(L->listsize+increment)*sizeof(ElemType));
if(!newbase) exit(OVERFLOW);
L->elem = newbase;
L->listsize += increment;
return OK;
}
//初始条件:线性表L已存在
//操作结果:销毁线性表L
Status DestroyList(SqList *L){
if(0==L->listsi
线性表的顺序表示和实现:sqlist
最新推荐文章于 2022-08-01 14:43:16 发布