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

相关推荐
糖果店的幽灵12 小时前
langgraph的 MessagesState 解读
java·开发语言·人工智能·windows·langgraph
闪电悠米12 小时前
力扣hot100-41.缺失的第一个正数-原地哈希详解
数据结构·算法·哈希算法
WL学习笔记13 小时前
堆(数据结构)
数据结构·
骑上单车去旅行13 小时前
MD5校验对比脚本
linux·服务器·windows
FreeBuf_16 小时前
Windows NT OS内核提权漏洞PoC已公开
windows
wabs66617 小时前
关于图论【卡码网100.最大岛屿的面积的思考】
数据结构·算法·图论
雲帝17 小时前
Windows虚拟机UDP大包分片排障
windows·网络协议·udp
李少兄17 小时前
Windows 键盘快捷键指南
windows·计算机外设·快捷键
寒水馨18 小时前
Windows下载、安装scrcpy-v4.1(附安装包scrcpy-win64-v4.1.zip)
windows·scrcpy·投屏工具·安卓投屏·usb调试·android投屏·屏幕镜像
yuannl1018 小时前
图的最短路径Dijkstra
数据结构