当前位置:网站首页>双链表有关操作
双链表有关操作
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;
}
销毁一个双链表
双链表的遍历
边栏推荐
- 使用set_handler过滤掉特定的SystemC Wraning &Error Message
- Custom grpc plug-in
- Computer graduation project asp Net attendance management system vs developing SQLSERVER database web structure c programming computer web page source code project
- Redis的攻击手法
- C serialization simple experiment
- About keil compiler, "file has been changed outside the editor, reload?" Solutions for
- [Yunju entrepreneurial foundation notes] Chapter 7 Entrepreneurial Resource test 6
- Sum of factor numbers of interval product -- prefix sum idea + fixed one shift two
- 【20211129】Jupyter Notebook远程服务器配置
- Mechanism and type of CPU context switch
猜你喜欢
LeetCode力扣(剑指offer 31-35)31. 栈的压入弹出序列32I.II.III.从上到下打印二叉树33. 二叉搜索树的后序遍历序列34. 二叉树中和为某一值的路径35. 复杂链表的复制
博途V15添加GSD文件
S7-1500plc simulation
Istio, ebpf and rsocket Broker: in depth study of service grid
[Yunju entrepreneurial foundation notes] Chapter VII Entrepreneurial Resource test 1
Typora realizes automatic uploading of picture pasting
ABBIRB120工业机器人机械零点位置
Machine learning - Data Science Library - day two
Botu V15 add GSD file
Powerful, easy-to-use, professional editor / notebook software suitable for programmers / software developers, comprehensive evaluation and comprehensive recommendation
随机推荐
NOV Schedule for . Net to display and organize appointments and recurring events
241. Design priority for operational expressions: DFS application questions
Leetcode (Sword finger offer) - 58 - ii Rotate string left
LeetCode力扣(剑指offer 31-35)31. 栈的压入弹出序列32I.II.III.从上到下打印二叉树33. 二叉搜索树的后序遍历序列34. 二叉树中和为某一值的路径35. 复杂链表的复制
Chen Gong: Micro service, is it still so pure?
Message queue monitoring refund task batch process
Software project management 9.2 Software project configuration management process
91. (chapitre Cesium) simulation de lancement de fusées cesium
Machine learning - Data Science Library - day two
Le semester manquant
Abbirb120 industrial robot mechanical zero position
华为HMS Core携手超图为三维GIS注入新动能
S7-1500PLC仿真
Self organization is the two-way rush of managers and members
[Yunju entrepreneurial foundation notes] Chapter 7 Entrepreneurial Resource test 4
邻接矩阵无向图(一) - 基本概念与C语言
比特熊直播间一周年,英雄集结令!邀你来合影!
Istio, ebpf and rsocket Broker: in depth study of service grid
CPU 上下文切换的机制和类型 (CPU Context Switch)
C summary of knowledge points 1