直接上代码
#include<stdio.h>
#include<stdlib.h>
#define OK 1
#define ERROR 0
#define MAXSIZE 100
typedef int Status;
typedef int ElemType;
typedef struct
{
ElemType *elem;//*elem存储空间的基地址
int length;
}Sqlist;
Sqlist L;
Status Initlist(Sqlist &L)//构造一个空的线性表
{
L.elem=new ElemType[MAXSIZE];
if(!L.elem)
return ERROR;
L.length=0;
return OK;
}
int GetElem(Sqlist L,int i,ElemType &e)
{
if(i<1||i>L.length)
return ERROR;
e=L.elem[i-1];//第i-1个单元存储着第i个数据
return OK;
}
//清空线性表
int ClearList(Sqlist &L)
{
L.length=0;
return OK;
}
//判断线性表是否为空
int IsEmpty(Sqlist L)
{
if(L.length==0)
return OK;
}
//获取线性表的长度
int Getlength(Sqlist L)
{
return(L.length);
}
int DestoryList