第1页共51页(线性表顺序存储)#include"string
h"#include"ctype
h"#include"stdio
h"#include"stdlib
h"#include"io
h"#include"math
h"#include"time
h"#defineOK1#defineERROR0#defineTRUE1#defineFALSE0#defineMAXSIZE20/*存储空间初始分配量*/typedefintStatus;/*Status是函数的类型,其值是函数结果状态代码,如OK等*/typedefintElemType;/*ElemType类型根据实际情况而定,这里假设为int*/Statusvisit(ElemTypec){printf("%d",c);returnOK;}typedefstruct{ElemTypedata[MAXSIZE];/*数组,存储数据元素*/intlength;/*线性表当前长度*/}SqList;/*初始化顺序线性表*/StatusInitList(SqList*L){L->length=0;returnOK;}/*初始条件:顺序线性表L已存在
操作结果:若 L为空表,则返回 TRUE,否则返回 FALSE*/StatusListEmpty(SqListL){if(L
length==0)returnTRUE;elsereturnFALSE;}/*初始条件:顺序线性表L已存在
操作结果:将 L重置为空表*/StatusClearList(SqList*L){L->length=0;returnOK;}/*初始条件:顺序线性表L已存在
操作结果:返回 L中数据元素个数*/intListLength(SqListL){returnL
length;}/*初始条件:顺序线性表L已存在,1≤i≤ListLength(L)