📄 sqlist.h
字号:
#include "malloc.h"
#include "iostream.h"
#include "conio.h"
//函数结果状态代码
#define TRUE 1
#define FALSE 0
#define OK 1
#define ERROR 0
#define INFEASIBLE -1
#define OVERFLOW -2
#define LIST_INIT_SIZE 100 //线性表存储空间的初始分配量
#define LISTINCREMENT 10 //线性表存储空间的分配增量
typedef int Status;//status是函数的类型,其值是函数结果状态代码
typedef int ElemType; //线性表的元素类型
typedef struct
{
ElemType * elem; //存储空间基址
int length; //当前长度
int listsize; //当前分配的存储容量(以sizeof(ElemType)为单位)
}Sqlist;
Status InitList_Sq(Sqlist &);//构造一个空的线形表
void DestroyList_Sq(Sqlist &);//销毁线性表
Status ClearList(Sqlist &L);//将L重置为空表
Status CreateList_Sq(Sqlist &L);//键盘输入线性表的初始长度,各个元素,创建顺序表
Status ListEmpty_Sq(Sqlist L);//判断L是否为空表
int ListLength_Sq(Sqlist L);//返回L数据的个数
Status GetElem_Sq(Sqlist L,int i,ElemType &e);//用e返回L中第i个数据元素的值
int LocateElem_Sq(Sqlist L,ElemType e,Status (*compare)(ElemType e1,ElemType e2));//返回L中第一个与e满足关系compare()的元素的位置
Status PriorElem_Sq(Sqlist L,ElemType cur_e,ElemType &pre_e);//返回前驱
Status NextElem_Sq(Sqlist L,ElemType cur_e,ElemType &next_e);//返回后继
Status ListInsert_Sq(Sqlist &L,int i,ElemType e);//在第i个位置之前插入新的元素e
Status ListDelete_Sq(Sqlist &L,int i,ElemType &e);//删除第i个元素,并用e返回其值
void ListDisplay_Sq(Sqlist L);//显示顺序表的内容
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -