数据结构复习-day01
SqList顺序表
//SKinBoy
#include<bits/stdc++.h>
using namespace std;
#define MAXSIZE 20
#define OK 1
#define ERROR 0
#define TRUE 1
#define FALSE 0
typedef int ElemType;
typedef int Status;
//以上定义看似繁琐,但如果在VScode等编辑器中打代码你会发现,会有关键字提醒,能够极大提高coding效率
typedef struct{
//typedef不可省
ElemType data[MAXSIZE];//数组数据元素
int length;//线性表长度
}SqList;
//查
Status GetElem(SqList L,int i,ElemType *e){
//get第i个位置的值
if(L.length==0 || i<1 ||i>L.length)
return ERROR;
*e=L.data[i-1];//因为是第i个位置所以返回data【i-1】
return OK;
}
//增
Status ListInster(SqList *L,int i,ElemType e){
//在L中的第i位插入元素e
//因为涉及到数组的值的改变,所以L要用指针类型*L
int k