数据结构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

相关推荐
测绘第一深情14 小时前
在vscode中使用codex教程(个人安装经验)
数据结构·ide·vscode·python·算法·计算机视觉·编辑器
Byron Loong14 小时前
【逆向】Windows 三大注入:远程线程 、APC 、 钩子注入
windows
Liangwei Lin14 小时前
LeetCode 41. 缺失的第一个正数
数据结构·算法·leetcode
凤舞飘伶14 小时前
windows安装docker-desk
windows·docker·容器
绿豆人15 小时前
Cache缓存项目学习4
windows·学习·缓存
平行侠15 小时前
022Miller-Rabin 概率素性检验 - 概率与数论的完美联姻
数据结构·算法
wuweijianlove15 小时前
算法与数据结构协同优化的设计思想的技术7
数据结构·算法
故事和你9115 小时前
洛谷-数据结构2-1-二叉堆与树状数组1
开发语言·数据结构·c++·算法·动态规划·图论
LuDvei15 小时前
Windows x86 架构下 Ubuntu 虚拟机内打包 Qt 文件指南
windows·qt·ubuntu
多加点辣也没关系16 小时前
数据结构与算法|第十七章:贪心算法
数据结构·算法·贪心算法