关于线性表的顺序实现很多地方都有介绍,原理阐述的也都很清晰,但新人对于伪代码总会有一些地方不好理解,刚好前几天写了一下用c++实现的代码,在这里贴出来,希望大家能多多指教,也希望能给新手一点儿启发。
#define TRUE 1
#define FALSE 0
#define OK 1
#define ERROR 0
#define OVERFLOW -2
#define LIST_INIT_SIZE 100
#define LISTINCREMENT 10
#include<malloc.h>
#include<process.h>
#include<iostream.h>
typedef int ElemType;
typedef int Status;
//线性表的空间分配
typedef struct{
ElemType *elem;
ElemType length;
ElemType listsize;
}SqList;
//初始化线性表
Status InitList_Sq(SqList &L){
L.elem=(ElemType *)malloc(LIST_INIT_SIZE*sizeof(ElemT