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

相关推荐
旖-旎16 分钟前
链表(两两交换链表中的节点)(2)
数据结构·c++·学习·算法·链表·力控
dyj09523 分钟前
OpenClaw小龙虾本地部署【Windows系统 + 接入飞书】
windows·飞书
CresCent_Charles1 小时前
(已解决)踩坑记录:Windows 11安装pointops编译时报错
windows
会编程的土豆1 小时前
【数据结构与算法】堆排序
开发语言·数据结构·c++·算法·leetcode
会编程的土豆1 小时前
【数据结构与算法】希尔排序
数据结构·c++·算法·排序算法
skywalk81631 小时前
Windows下安装编译安装Whisper-CPP:一个语音实现框架集和高性能推理模型
人工智能·windows·whisper
charlie1145141911 小时前
通用GUI编程技术——图形渲染实战(二十五)——Alpha混合与透明效果:分层窗口实战
c++·windows·学习·图形渲染·win32
charlie1145141911 小时前
通用GUI编程技术——图形渲染实战(二十四)——GDI Region与裁切:不规则窗口与可视化控制
c++·windows·学习·c·图形渲染·win32
极梦网络无忧1 小时前
Windows UI Automation实现抖音直播间监控(桌面端场控助手核心方案)
windows·ui
汀、人工智能1 小时前
[特殊字符] 第73课:打家劫舍
数据结构·算法·数据库架构·图论·bfs·打家劫舍