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

相关推荐
01292520几秒前
列表之链表_C
c语言·windows·链表
sml259(劳改版)4 分钟前
(PTA) L2-011-L2-015
数据结构·算法
梦道长生23 分钟前
GPT-SoVITS Windows 配置与推理笔记(自用)
人工智能·windows·笔记·gpt
末央&2 小时前
【C++】list底层封装和实现
c++·windows·list
风铃儿~2 小时前
Redis过期key处理、内存淘汰策略与缓存一致性策略实践方案
java·数据结构·redis·微服务
啾啾Fun2 小时前
[Redis]redis-windows下载安装与使用
数据库·windows·redis
大龄门外汉2 小时前
数据结构之栈和队列
c语言·数据结构·学习·改行学it
攻城狮7号3 小时前
【第39节】windows编程:打造MFC版本任务管理器
c++·windows·mfc·任务管理器
朝九晚五ฺ3 小时前
【算法学习】链表篇:链表的常用技巧和操作总结
数据结构·学习·算法·链表
what_20183 小时前
Linux启动端口,Windows 看是否通
windows