顺序表及其基本操作
代码部分:
#include<stdio.h>
#include<stdlib.h>
#define OVERFLOW -2
#define OK 1
#define ERROR 0
#define TRUE 1
#define FALSE 0
#define LIST_INIT_SIZE 100
#define LISTINCREMENT 10
typedef int ElemType;
typedef int Status;
typedef struct
{
ElemType *elem;
int length;
int listsize;
}SqList;
void mainmenu(); //主菜单
Status InitList_Sq(SqList &L); //初始化
int putlist(SqList &L); //填入数据
void DestroyList(SqList &L); //销毁
void ListEmpty(SqList L); //判断表空
Status ListLength(SqList L); //测量表长
Status ListInsert_Sq(SqList &L,int i,ElemType e); //插入
Status ListDelete_Sq(SqList &L,int i,ElemType &e); //删除
int LocateElem_Sq(SqList L,ElemType e); //查询
Status ClearList(SqList &L); //清空
Status GetElem_Sq(SqList L,int i,ElemType &e); //获取指定位置的元素
void PrintList_Sq(SqList L); //输出
SqList L;
int main()
{
while(1)
{
mainmenu();
}
return 0;
}
void mainmenu() //主菜单
{
int i,x,m1,m2,length;
ElemType e;
system("cls");
printf("\n\t***************顺序表及其基本操作***************\n\n");
printf("\n\t---------------[1]创建---------------");
printf("\n\t---------------[2]销毁---------------");
printf("\n\t---------------[3]判断表空---------------");
printf("\n\t---------------[4]测量表长---------------");