当前位置:网站首页>静态链表
静态链表
2022-07-23 05:42:00 【你看那是一个舔狗】
#include <stdio.h>
#define MAXSIZE 20
typedef int T;
typedef struct
{
T data;
int cur;
}StaticList[MAXSIZE];
int LengthList(StaticList L)//数据个数
{
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)//若备用空间链表非空,则返回分配的结点下标
{
int i = space[0].cur;
if (space[0].cur)
space[0].cur = space[i].cur;
return i;
}
void Free(StaticList space, int k)//将下标为k的空闲结点回收到备用链表
{
space[k].cur = space[0].cur;
space[0].cur = k;
}
bool InterList(StaticList L, int i,T val)//在L中第i个元素之前插入新的数据元素
{
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)//遍历
{
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)//删除在L中的第i个数据元素
{
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;
}
边栏推荐
- 高德定位---权限弹框不出现的问题
- NFT digital collection system development: the combination of music and NFT
- Ten year structure five year life-01 at the beginning of graduation
- 1.认识数据库
- 3. DQL (data query statement)
- Usage of some, every, find, FindIndex
- Data warehouse 4.0 notes - user behavior data collection I
- MySQL存储引擎
- 9、 Practical class
- 八、集合框架和泛型
猜你喜欢

10. I/o input / output stream

Mosaic the face part of the picture

Image fuzzy processing batch production fuzzy data set

数仓4.0笔记——用户行为数据采集一

New BPMN file used by activiti workflow

Activiti7 Quick Start experience sharing

9、 Practical class

Machine learning algorithm for large factory interview (5) recommendation system algorithm

MySQL存储引擎

NFT digital collection development: Jingdong "Qida bear takes you to the capital" tourism package
随机推荐
3、DQL(数据查询语句)
编译原理-语法分析详解
第一阶段复习
1、MySQL初体验
Internet communication
數倉4.0筆記——用戶行為數據采集四
1. Know the database
mysql树形结构递归查询
Introduction to the process structure used by activiti workflow
Review of knowledge points
Window runs gradle build ----- stacktrace. Exception occurs when the file framework-4.3.0.build-snapshot-schema.zip is not found
[doris] configure and basically use the contents system (continue to add content when you have time)
11. Multithreading
用户连续登陆(允许中断)查询sql
Typescript introduction
九、实用类
mysql根据中文字段首字母排序
MySQL数据库
[pyautogui learning] screen coordinates and mouse scrolling
[pyrodiomics] the extracted image omics characteristic value is abnormal (many 0 and 1)