//库函数头文件包含 #include #include #include //函数状态码定义 #define TRUE 1 #define FALSE 0 #define OK 1 #define ERROR 0 #define INFEASIBLE -1 #define OVERFLOW -2 typedef int Status; //顺序表的存储结构定义 #define LIST_INIT_SIZE 100 #define LISTINCREMENT 10 typedef int ElemType; //假设线性表中的元素均为整型 typedef struct{ ElemType* elem; //存储空间基地址 int length; //表中元素的个数 int listsize; //表容量大小 }SqList; //顺序表类型定义 Status ListCreate_Sq(SqList &L) { int n; scanf("%d",&n); L.elem=new ElemType[LIST_INIT_SIZE];//为顺序表分配一个大小为LIST_INIT_SIZE的数组空间 //L.elem=(ElemType *)malloc(LIST_INIT_SIZE*sizeof(ElemType));跟上一句作用一样,都是分配空间 if(!L.elem) exit(OVERFLOW);//储存分配失败退出 L.length=0;//空表长度为0 L.listsize=LIST_INIT_SIZE;//顺序表大小为LIST_INIT_SIZE for(int i=0;i