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

相关推荐
泓铮7 小时前
Windows 环境下 WSL2 与 VMware Workstation 17 共存机制研究与工程实践
windows
澈2077 小时前
深入浅出C++滑动窗口算法:原理、实现与实战应用详解
数据结构·c++·算法
ambition202427 小时前
从暴力搜索到理论最优:一道任务调度问题的完整算法演进历程
c语言·数据结构·c++·算法·贪心算法·深度优先
代码旅人ing8 小时前
链表算法刷题指南
数据结构·算法·链表
不爱吃炸鸡柳9 小时前
单链表专题(完整代码版)
数据结构·算法·链表
Morwit10 小时前
【力扣hot100】 1. 两数之和
数据结构·c++·算法·leetcode·职场和发展
明湖起风了10 小时前
mqtt消费堆积
java·jvm·windows
私人珍藏库10 小时前
[Windows] 【灵犀Claw生成】酷狗加密音乐批量转换工具 Xy Music Converter
windows·工具·软件·多功能
handsomestWei12 小时前
claude-code在win环境安装使用
windows·ai编程·claude·安装配置·cc-switch
田梓燊13 小时前
2026/4/11 leetcode 3741
数据结构·算法·leetcode