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

相关推荐
kkeeper~1 小时前
0基础C语言积跬步之数据在内存中的存储
c语言·数据结构·算法
2401_868534781 小时前
论企业网络设计
数据结构
不总是2 小时前
Windows 系统 Node.js 免安装版(zip)安装与配置教程(2026 最新)
前端·windows·node.js
2401_876964132 小时前
【湖北专升本】2026湖北专升本真题PDF+备考资料汇总
数据结构·人工智能·经验分享·深度学习·算法·计算机视觉
不总是4 小时前
[2026最新] Windows 免安装版 MySQL 8 详细安装配置教程(ZIP 压缩包版)
数据库·windows·mysql
2401_876964135 小时前
27考研余炳森概率论|喻老李良2027资料网课
windows·git·考研·svn·eclipse·github·概率论
介一安全6 小时前
【漏洞学习】PHP+Windows环境通用文件上传漏洞深度剖析
windows·web安全·php·文件上传·安全性测试
思麟呀6 小时前
C++工业级日志项目(六)异步日志器
linux·c++·windows
c238566 小时前
vector(下)
数据结构·算法
z落落6 小时前
C# 冒泡排序+选择排序 + Array.Sort 自定义排序
数据结构·算法