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

相关推荐
liu****20 小时前
16.udp_socket(三)
linux·开发语言·数据结构·c++·1024程序员节
Rock_yzh21 小时前
LeetCode算法刷题——49. 字母异位词分组
数据结构·c++·学习·算法·leetcode·职场和发展·哈希算法
小欣加油21 小时前
leetcode 2654 使数组所有元素变成1的最少操作次数
数据结构·c++·算法·leetcode·职场和发展
芳草萋萋鹦鹉洲哦1 天前
【Windows】tauri+rust运行打包工具链安装
开发语言·windows·rust
会跑的兔子1 天前
Android 16 Kotlin协程 第二部分
android·windows·kotlin
hhhh明1 天前
quest2+alvr+steamvr
linux·windows·quest2
码银1 天前
【数据结构】顺序表
java·开发语言·数据结构
小张成长计划..1 天前
【C++】List容器的理解和使用(超详细)
数据结构·list
AimerDaniil1 天前
windows 根据端口号关闭进程脚本
windows