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

相关推荐
OOJO1 分钟前
c++---list介绍
c语言·开发语言·数据结构·c++·算法·list
田梓燊2 小时前
code 560
数据结构·算法·哈希算法
会编程的土豆3 小时前
【数据结构与算法】动态规划
数据结构·c++·算法·leetcode·代理模式
迈巴赫车主4 小时前
蓝桥杯19724食堂
java·数据结构·算法·职场和发展·蓝桥杯
Kethy__4 小时前
计算机中级-数据库系统工程师-数据结构-查找算法
数据结构·算法·软考·查找算法·计算机中级
所以遗憾是什么呢?4 小时前
【题解】Codeforces Round 1081 (Div. 2)
数据结构·c++·算法·acm·icpc·ccpc·xcpc
雨浓YN5 小时前
OPC UA 通讯开发笔记 - 基于本地dll文件
windows·笔记
大强同学5 小时前
Obsidian CLI + Claude Code = 王炸组合
人工智能·windows·ai编程·cli
OOJO5 小时前
c++---vector介绍
c语言·开发语言·数据结构·c++·算法·vim·visual studio
茉莉玫瑰花茶5 小时前
数据结构 - 并查集
数据结构