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

相关推荐
十二2 小时前
【洛谷题解】P1083 [NOIP 2012 提高组] 借教室(二分答案 + 差分)
数据结构·c++·算法·蓝桥杯
D e re k ZH4 小时前
C++ 从零入门(一):基础语法与程序结构
数据结构·c++·算法
没差c8 小时前
winsw将jar、nginx等注册为Windows服务
windows·nginx·jar
光谱SpectrAI9 小时前
Claude Code 2.1.318 的隐私模块:4 条命令,拦了 2 条
windows
careathers9 小时前
【数据结构】基于比较的排序算法 - 交换排序
数据结构·算法·排序算法
H.莓飛10 小时前
【C++】【STL】vector_OJ题
linux·服务器·开发语言·数据结构·c++·visual studio
Hello_Pyhx11 小时前
NWinfo 导出 Windows 硬件信息:从 JSON 报告到缺项排查
windows·json
老师我太想进步了20261 天前
【数据结构-4】算法美学之顺序表
数据结构·算法
百事牛科技1 天前
Excel的三种密码:防看、防存、防乱改,各管各的
windows·excel
GrowingIO技术社区1 天前
CDP、行为分析、归因与营销自动化有什么区别?
数据结构·数据挖掘·数据分析