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

相关推荐
胖咕噜的稞达鸭1 小时前
AVL树手撕,超详细图文详解
c语言·开发语言·数据结构·c++·算法·visual studio
阿林学习计算机2 小时前
红黑树的实现
数据结构
至善迎风2 小时前
将跨平台框架或游戏引擎开发的 Windows 应用上架 Microsoft Store
windows·microsoft·游戏引擎
皮皮冰燃2 小时前
关系数据库-10-[mysql5和mysql8]在windows中安装为服务并共存
windows·mysql
太空1号2 小时前
VxWorks入门小白菜鸟教程3 —— 编译运行VxWorksSDK示例hello_cmake_rtp(Windows篇)
windows·嵌入式硬件
天朝八阿哥2 小时前
Bye~~ win10!
linux·windows
豐儀麟阁贵2 小时前
4.4数组的基本操作
java·开发语言·数据结构·算法
景彡先生2 小时前
Python列表(List)完全指南:从入门到实战优化
windows·python·list
无限进步_2 小时前
【C语言】在矩阵中高效查找数字的算法解析
c语言·开发语言·数据结构·c++·其他·算法·矩阵
Yupureki3 小时前
从零开始的C++学习生活 11:二叉搜索树全面解析
c语言·数据结构·c++·学习·visual studio