数据结构2月25日

第一道:

第二道:

1、插入到prev和next中间

1.new=(struct list_head*)malloc(sizeof(struct list_head*));

if(new==NULL)

{

printf("失败\n");

return;

}

new->next=prev->next;

prev->next=new;

return;

2、删除prve和next中间那个

2.struct list_head* p=prev->next;

prev->next=p->next;

p->next->prev=prev;

free(temp);

temp=NULL;

return;

插入到队尾

  1. struct list_head3* temp = (struct list_head*)malloc(sizeof(struct list_head*));

if(temp==NULL)

{

printf("结点申请失败,插入失败\n");

return;

}

struct list_head* p=head;

while(p->next!=NULL)

{

p=p->next;

}

temp->next=NULL;

p->next=temp;

temp->prev=p;

return;

  1. entry->next->prev=entry->prev;

entry->prev->next=entry->next;

free(entry);

entry=NULL;

return;

判断是否为空

  1. if(head->next==NULL)

{

printf("链表为空\n");

}

return;


版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。

原文链接:https://blog.csdn.net/m0_67565143/article/details/136286971

相关推荐
流氓也是种气质 _Cookie7 分钟前
Wireshark在Windows XP系统上的安装与使用指南
windows·测试工具·wireshark
寒秋花开曾相惜35 分钟前
(学习笔记)第四章 处理器体系结构
linux·网络·数据结构·笔记·学习
故事和你911 小时前
洛谷-数据结构1-1-线性表1
开发语言·数据结构·c++·算法·leetcode·动态规划·图论
脱氧核糖核酸__1 小时前
LeetCode热题100——53.最大子数组和(题解+答案+要点)
数据结构·c++·算法·leetcode
脱氧核糖核酸__2 小时前
LeetCode 热题100——42.接雨水(题目+题解+答案)
数据结构·c++·算法·leetcode
自我意识的多元宇宙3 小时前
二叉树遍历方式代码解读(2迭代)
数据结构
脱氧核糖核酸__3 小时前
LeetCode热题100——238.除了自身以外数组的乘积(题目+题解+答案)
数据结构·c++·算法·leetcode
再卷也是菜3 小时前
算法提高篇(1)线段树(上)
数据结构·算法
杨凯凡4 小时前
【012】图与最短路径:了解即可
java·数据结构
j_xxx404_4 小时前
C++算法:哈希表(简介|两数之和|判断是否互为字符重排)
数据结构·c++·算法·leetcode·蓝桥杯·力扣·散列表