当前位置:网站首页>Static linked list
Static linked list
2022-07-23 11:59:00 【Look, that's a licking dog】
#include <stdio.h>
#define MAXSIZE 20
typedef int T;
typedef struct
{
T data;
int cur;
}StaticList[MAXSIZE];
int LengthList(StaticList L)// The number of data
{
int i = 0;
int j = L[MAXSIZE - 1].cur;
while (i)
{
i = L[i].cur;
j++;
}
return j;
}
bool InitStList(StaticList space)
{
for (int i = 0; i < MAXSIZE; i++)
space[i].cur = i + 1;
space[MAXSIZE - 1].cur = 0;
return true;
}
int Malloc(StaticList space)// If the spare space linked list is not empty , Then the allocated node subscript is returned
{
int i = space[0].cur;
if (space[0].cur)
space[0].cur = space[i].cur;
return i;
}
void Free(StaticList space, int k)// Mark the subscript as k The idle nodes are recycled to the spare list
{
space[k].cur = space[0].cur;
space[0].cur = k;
}
bool InterList(StaticList L, int i,T val)// stay L pass the civil examinations i Insert a new data element before an element
{
int j, k, l;
T e;
k = MAXSIZE - 1;
if (i<i || i>LengthList(L) + 1)
return false;
j = Malloc(L);
if (j)
{
L[j].data = val;
for (l = 1; l <= i - 1; l++)
k = L[k].cur;
L[j].cur = L[k].cur;
L[k].cur = j;
return true;
}
return false;
}
void Show(StaticList L)// Traverse
{
int i = L[MAXSIZE - 1].cur;
while (i)
{
printf("%d ", L[i].data);
i = L[i].cur;
}
printf("\n");
}
bool DeleteList(StaticList L, int i)// Delete on L No i Data element
{
int j, k;
if (i<1 || i>LengthList(L))
return false;
k = MAXSIZE - 1;
for (j = 1; j <= i - 1; j++)
k = L[k].cur;
j = L[k].cur;
L[k].cur = L[j].cur;
Free(L, j);
return true;
}
int main()
{
return 0;
}
Give a link , You can see for yourself what you want to know
边栏推荐
猜你喜欢
随机推荐
1. Initial experience of MySQL
Internet communication
百变冰冰!使用飞桨的PaddleGAN实现妆容迁移
10、I/O 输入输出流
MySQL uninstall
数仓4.0笔记---用户行为数据生成
串
Mosaic the face part of the picture
Machine learning algorithm for large factory interview (5) recommendation system algorithm
Data warehouse 4.0 notes - Data Warehouse Modeling
[metric] use Prometheus to monitor flink1.13org.apache.flink.metrics
[untitled]
Method of recognizing b value from DICOM tag in DWI image
Websocket long connection
uni原生插件开发--友盟一键登录
两个栈共用空间
Charles抓包的使用步骤
[hudi]hudi compilation and simple use of Hudi & spark and Hudi & Flink
ninja文件语法学习
Project instances used by activiti workflow





![[hudi]hudi compilation and simple use of Hudi & spark and Hudi & Flink](/img/6f/e6f5ef79c232d9b27a8334cd8ddaa5.png)


![[system problems] Net Framework 3.5 installation error](/img/a1/f5410e954b607d5c0549051bd68aa1.png)