实现顺序表的各种基本运算一、实验目的了解顺序表的结构特点及有关概念,掌握顺序表的各种基本操作算法思想及其实现。 二、实验内容 编写一个程序,实现顺序表的各种基本运算: 1、初始化顺序表; 2、顺序表的插入; 3、顺序表的输出; 4、求顺序表的长度 5、判断顺序表是否为空; 6、输出顺序表的第 i 位置的个元素 ; 7、在顺序表中查找一个给定元素在表中的位置; 8、顺序表的删除; 9、释放顺序表三、算法思想与算法描述简图主函数 mainvoid InitList(SqList*&L) 初始化顺序表void DestroyList(SqList*&L)// 释放顺序表 Lint ListEmpty(SqList*L)// 判断顺序表 L 是否为空集int Listlength(SqList*L)// 返回顺序表 L 的元素个数void DispList(SqList*L)// 输出顺序表 Lint GetElem(SqList*L,int i,char e)/*ElemType e) 获取顺序表 L 中的第 i 个元素 */int LocateEmpty(SqList*L,char e)/*ElemType e) 在顺序表 L 中查找元素 e*/int ListInsert(SqList*&L,int i,char e)/*ElemType e)在顺序表中第 i 个位置上插入元素 e*/int ListDelete(SqList*&L,int i,char &e)/*ElemType e)在顺序表 L 中删除第 i 个元素 */四、实验步骤与算法实现#include#include#define MaxSize 50typedef char ElemType;typedef struct{ElemType data[MaxSize];int length;}SqList;//顺序表类型的定义void InitList(SqList*&L)//初始化顺序表 L{L=(SqList*)malloc(sizeof(SqList));L->length=0;}void DestroyList(SqList*&L)//释放顺序表 L{free(L);}int ListEmpty(SqList*L)//判断顺序表 L 是否为空集{return(L->length==0);}int Listlength(SqList*L)//返回顺序表 L 的元素个数{return(L->length);}void DispList(SqList*L)//输出顺序表 L{int i;if(ListEmpty(L))return;for(i=0;ilength;i++)printf("%c",L->data[i]);printf("\n");}int GetElem(SqList*L,int i,ElemType e)/*获取顺序表 L 中的第 i 个元素*/{if(i<1||i>L->length)//查找是否有这个 i,若没有返回 0return 0;e=L->data[i-1];return 1;}int LocateEmpty(SqList*L,ElemType e)/*在顺序表 L 中查找元素 e*/{int i=0;while (ilength&&L->data[i]!=e)i++;if(i>=L->length)return 0;else return i+1;}int ListInsert(SqList*&L,int i,ElemType e)/*在顺序表中第...