predefine.h
//预定义函数返回结果头文件
//文件名pre_define.h
//函数结果状态代码
#define TRUE 1
#define FALSE 0
#define OK 1
#define ERROR 0
#define INFEASIBLE -1
#define OVERFLOW -2
#define UNDERFLOW -2
//假设数组维数的最大值为8
#define MAX_ARRAY_SIZE 8
//Status是函数的类型,其值是函数结果状态代码
typedef int Status;
//Boolean是布尔类型,其值是TRUE或FALSE
typedef int ElemType;
SqList.cpp <pre name="code" class="cpp"#include "pre_define.h"#include <stdio.h>#include <stdlib.h>#include <malloc.h>#define LIST_INIT_SIZE 100 // 线性表存储空间的初始分配量#define LISTINCREMENT 10 // 线性表存储空间的分配增量typedef struct{ElemType *elem; // 存储空间基址int length; // 当前长度int listsize; // 当前分配的存储容量} SqList;bool compare(ElemType e1, ElemType e2){if (e1 == e2)return true;return false;}Status InitList_Sq(SqList &L){// 构造一个空的线性表LL.elem = (ElemType *)malloc