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

相关推荐
q***016533 分钟前
Windows操作系统部署Tomcat详细讲解
java·windows·tomcat
Live&&learn3 小时前
算法训练-数据结构
数据结构·算法·leetcode
胡萝卜3.04 小时前
掌握C++ map:高效键值对操作指南
开发语言·数据结构·c++·人工智能·map
Neur0toxin5 小时前
入侵排查_2025/11/23
linux·windows·应急响应
风筝在晴天搁浅5 小时前
代码随想录 509.斐波那契数
数据结构·算法
落落落sss5 小时前
java实现排序
java·数据结构·算法
fei_sun6 小时前
【数据结构】2018年真题
数据结构
Wuuconix7 小时前
阿三系统疑难杂症解决(输入法 + 浏览器闪屏)
windows·阿三
SundayBear7 小时前
C语言复杂类型声明完全解析:从右左原则到工程实践
c语言·开发语言·数据结构·嵌入式
n***26567 小时前
Windows环境下安装Redis并设置Redis开机自启
数据库·windows·redis