数据结构
创建一个线性表
#define MAXSIZE 100 typedef struct { ElemType *elem; int length; } SqlList; Status InitList_Sq (SqlList & L) { // 构造一个空的顺序表 L.elem = new ElemType [MAXSIZE]; //为表分配空间 if(L.elem) exit(OVERFLOW); // 空表长度为0 L.length = 0; return OK; }
void DestoryList (SqlList &L) { if(L.elem) delete []L.elem; }
取值 e = L.elem[i-1]; // 取值赋给e; ElemType &e;
插入算法
删除