顺序表基本操作的代码如下:
#include<stdio.h>
#include<iostream>
#include<string>
#include<malloc.h>
#define LIST_INIT_SIZE 10
#define LIST_INC_SIZE 2
typedef enum {
OK = 1, ERROR = -1, POSERROR = -2, INITFAULT = -3, LISTEMPTY = -4, LISTFULL = -5, LISTNULL = -6
}Status;
using namespace std;
typedef int ElemType;
struct SeqList
{
ElemType *data;
int cursize;
int maxsize;
};
int Init(SeqList &sp)
{
sp.data = (ElemType*)malloc(sizeof(ElemType)*LIST_INIT_SIZE);
if (NULL == sp.data)
{
return INITFAULT;
}
memset(sp.data, 0, sizeof(ElemType)*LIST_INIT_SIZE);
sp.cursize = 0;
sp.maxsize = LIST_INIT_SIZE;
}
void DestroyList(SeqList &st)