#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
//还是有些问题,存档待复盘.
//实验一:顺序存储结构实现线性表的基本运算
//函数结果状态代码
#define TRUE 1
#define FALSE 0
#define OK 1
#define ERROR 0
#define INFEASIBLE -1
#define OVERFLOW -2
//Status是函数的类型,其值是函数结果状态代码
typedef int Status;
//数据元素类型定义
typedef struct{
int item1;
}ElemType;
//----线性表的动态分配顺序存储结构---
#define LIST_INIT_SIZE 100 //P22-线性表存储空间的初始分配量
#define LISTINCREMENT 10 //线性表存储空间的分配增量
typedef struct{
//定义顺序表L的结构体
ElemType *elem; //存储空间基址 数组指针elem指示线性表的基地址
int length; //当前长度
int listsize; //当前分配的存储容量,以sizeof(ElemType)为单位
}SqList;
//函数声明
Status IntiaList(SqList * L);
Status DestroyList(SqList * L);
Status ClearList(SqList L);
Status ListEmpty(SqList L);
int ListLength(SqList L);
Status GetElem(SqList L,int i,ElemType *e);
Status LocateElem(SqList L,ElemType e);
Status PriorElem(SqList L,ElemType cur_e,ElemType * pre_e);
Status NextElem(SqList L,ElemType cur,ElemType * next_e);
Status ListInsert(SqList *L, int i,ElemType e);
Status ListDelete(SqList * L,int i,ElemType * e);
Status ListTrabverse(SqList L);
Status compare(ElemType e1,ElemType e2);
Status visit(ElemType e);
Status compare(ElemType e1 ,ElemType e2){
//compare函数
if (e1.item1==e2.item1) return OK;
else return FALSE;
}
Status visit(ElemType e1){
//visit函数
printf("%d ",e1);
return OK;
}
void create(SqList *L){
//create函数:创建顺序线性表
int a=0,i=0;
printf("请输入你的线性表长度\n");
scanf("%d",&a);
//malloc:申请一块动态内存
L->elem=(ElemType*)malloc((a+1)*sizeof(ElemType));
L->length=a; //线性表L的长度设为a
printf("请输入你的数据\n");
for (i=1;i<