当前位置:网站首页>双链表有关操作
双链表有关操作
2022-07-01 12:05:00 【Between the steps】
双链表有关操作
双链表有关操作
双链表的初始化
#include<stdio.h>
typedef struct DNode{
int data;
struct DNode *prior,*next;
}DNode,*DLinklist;
//初始化双链表
bool InitDLinkList(DLinklist &L){
L=(DNode*)malloc(sizeof(DNode)); //分配一个头结点
if(L==NULL){
return false;
}
L->prior=NULL; //头结点的prior永远为NULL
L->next=NULL;
return true;
}
//链表判空
bool Empty(DLinklist L){
if(L->next==NULL)
return true;
else
return false;
}
void main(){
DLinklist L;
InitDLinkList(L);
}
双链表的插入
bool InsertNextDNode(DNode *p,DNode *s){
if(p==NULL||s==NULL){
return false;
}
s->next=p->next; //将结点*s插入到结点*p之后
if(p->next!=NULL)
p->next->prior=s;
s->prior=p;
p->next=s;
return true;
}


双链表结点的删除
//删除p结点的后继结点
bool InsertNextDNode(DNode *p){
if(p==NULL){
return false;
}
DNode *q=p->next; //找到p的后继结点
if(q==NULL){
return false; //p没有后继结点
}
p->next=q->next;
if(q->next!=NULL) //q结点不是最后一个结点
q->next->prior=p
free(q); //释放结点空间
return true;
}


销毁一个双链表
双链表的遍历
边栏推荐
- 区间乘积的因子数之和——前缀和思想+定一移二
- Chen Gong: Micro service, is it still so pure?
- 91. (chapitre Cesium) simulation de lancement de fusées cesium
- Typora adds watermarks to automatically uploaded pictures
- Unity xlua co process packaging
- 陈珙:微服务,它还那么纯粹吗?
- 力扣首页简介动画
- C knowledge point form summary 2
- Botu V15 add GSD file
- uniapp 使用 uni-upgrade-center
猜你喜欢

图的理论基础
![[Yunju entrepreneurial foundation notes] Chapter 7 Entrepreneurial Resource test 7](/img/41/e3ecbd49e4bfeab6c6e7d8733fe33a.jpg)
[Yunju entrepreneurial foundation notes] Chapter 7 Entrepreneurial Resource test 7

JS reverse | m3u8 data decryption of a spring and autumn network

Redis configuration environment variables

Joint Time-Frequency and Time Domain Learning for Speech Enhancement

Compile and debug net6 source code

Interpretation of R & D effectiveness measurement framework

Software project management 9.2 Software project configuration management process

Prepare for the Blue Bridge Cup Day10__ PWM control light brightness

Istio, ebpf and rsocket Broker: in depth study of service grid
随机推荐
uniapp 使用 uni-upgrade-center
Machine learning - Data Science Library Day 3 - Notes
Virtualenv+pipenv virtual environment management
Software project management 9.2 Software project configuration management process
Indefinite integral
Theoretical basis of graph
LeetCode 454. Add four numbers II
241. 为运算表达式设计优先级 : DFS 运用题
C summary of knowledge points 1
S7-1500PLC仿真
usb peripheral 驱动 - cable connect/disconnect
Machine learning - Data Science Library - day two
Golang des-cbc
Unity XLua 协程封装
Value/string in redis
How to understand the developed query statements
Botu V15 add GSD file
Leetcode (Sword finger offer) - 58 - ii Rotate string left
Value/list in redis
ABBIRB120工业机器人机械零点位置

