当前位置: 首页 > news >正文

互联网建网站变装小说 wordpress

互联网建网站,变装小说 wordpress,网站页面跳转怎么做,张家港外贸型网站建设-之前我们学过储存数据的一种表——顺序表,那么为什么还有链表呢 首先我们回顾一下顺序表 顺序表是物理地址连续的一段内存空间(数组),我们通过动态内存开辟的, 那么: 顺序表也有自己的一些优点&#xff0c…

-之前我们学过储存数据的一种表——顺序表,那么为什么还有链表呢
首先我们回顾一下顺序表
顺序表是物理地址连续的一段内存空间(数组),我们通过动态内存开辟的,
那么:在这里插入图片描述
顺序表也有自己的一些优点,比如我们之前做过的一些题,可以通过下标来快速完成,因为他的地址是连续的所以只要利用下标的加减就可以实现

既然顺序表有缺点,那么我们就有了链表。(按需求申请空间)

在这里插入图片描述
在这里插入图片描述
通过插入数据,来理解链表
在这里插入图片描述
在这里插入图片描述

打印函数
在这里插入图片描述

在链表的尾部插入数据

在这里插入图片描述

代码:


SLTPushBack(SLTNode* plist, SLTDataType x)
{//首先要开辟一个结构体来把要插入的数据的内容写进去,在之前的BuySListNode函数就是干这个事情的SLTNode* newnode = BuySListNode(x);SLTNode* tail = plist;while (tail->next != NULL){tail = tail->next;}tail->next = newnode;
}

上述的尾插是建立在之前已经头插了几个节点的情况下的
在这里插入图片描述

那么当链表还是空的时候,这样的尾插还适用吗
在这里插入图片描述
知道了这个问题我们来修改代码:
在这里插入图片描述
那么想要修改plist就要传址,
在这里插入图片描述
尾插总结图
在这里插入图片描述
头插:头插不管什么情况都要挪动plist的,所以也是传址操作,上面已经写到过头插的指针变换了,这里我们直接写代码就行

void TestSList3(){SLTNode* plist = NULL;SLTPushFront(&plist,5);SLTPushFront(&plist, 4);SLTPushFront(&plist, 3);SLTPushFront(&plist, 2);SLTPrin(plist);}void SLTPushFront(SLTNode** head, SLTDataType x)
{SLTNode* newnode = BuySListNode(x);newnode->next = *head;*head = newnode;}

在这里插入图片描述

尾删
在这里插入图片描述
代码:

//尾删SLTPopBack(&plist);SLTPrin(plist);SLTPopBack(&plist);SLTPrin(plist);SLTPopBack(&plist);SLTPrin(plist);SLTPopBack(&plist);SLTPrin(plist);SLTPopBack(&plist);SLTPrin(plist);
void SLTPopBack(SLTNode** head)
{assert(*head);if ((*head)->next == NULL){free(*head);*head = NULL;}else{SLTNode* stail = NULL;SLTNode* tail = *head;while (tail->next!=NULL){stail = tail;tail = tail->next;}free(tail);stail->next = NULL;}
}

在这里插入图片描述

头删
在这里插入图片描述

代码:

SLTPopFront(&plist);SLTPrin(plist);SLTPopFront(&plist);SLTPrin(plist);SLTPopFront(&plist);SLTPrin(plist);SLTPopFront(&plist);SLTPrin(plist);void SLTPopFront(SLTNode** head)
{assert(*head);SLTNode* newnode = (*head)->next;free(*head);*head = newnode;
}

在这里插入图片描述

查找链表中的数的指针,并改变这个指针所指节点的数据

在这里插入图片描述
代码:

//查找链表中的一个值的指针,并且改变他SLTNode* newnode = SLTFind(plist, 3);newnode->data = 20;SLTPrin(plist);
SLTNode* SLTFind(SLTNode* head, SLTDataType x)
{SLTNode* cur = head;while (cur != NULL){if (cur->data == x){return cur;}cur = cur->next;}return NULL;
}

在Pos位置插入节点
在这里插入图片描述
代码:

//在指定数据的指针pos位置前插入一个节点SLTNode* pos = SLTFind(plist, 3);//先查找到3所对应的指针posSLTnsert(&plist, pos, 30);SLTPrin(plist);
void SLTnsert(SLTNode** head, SLTNode* pos, SLTDataType x)
{assert(pos);if (pos == *head){SLTPushFront(head, x);//头插}else{SLTNode* prev = *head;while (prev->next != pos){prev = prev->next;//找到pos位置之前的那个节点的指针}SLTNode* newnode= BuySListNode(x);//为要插入的数据创建一个节点prev->next = newnode;newnode->next = pos;}
}

在这里插入图片描述
在pos位置之后插入节点
在这里插入图片描述
代码:

SLTNode* pos = SLTFind(plist, 3);//先查找到3所对应的指针pos/*	SLTnsert(&plist, pos, 30);SLTPrin(plist);*/SLTnsertAfter(plist, pos, 30);SLTPrin(plist);
void SLTnsertAfter(SLTNode* head, SLTNode* pos, SLTDataType x)
{assert(head);SLTNode* newnode = BuySListNode(x);//为要插入的数据创建一个节点newnode->next = pos->next;pos->next = newnode;
}

删除Pos位置的节点
在这里插入图片描述

SLTErase(&plist, pos);pos = NULL;SLTPrin(plist);void SLTErase(SLTNode** head, SLTNode* pos)
{assert(pos);if (pos == *head){SLTPopFront(head);//头删}else{SLTNode* per = *head;while (per->next!=pos){per = per->next;}per->next = pos->next;free(pos);}
}

删除pos位置之后的节点
在这里插入图片描述
代码:

SLTNode* pos = SLTFind(plist, 3);//先查找到3所对应的指针posSLTEraseAfter(pos);SLTPrin(plist);
void SLTEraseAfter(SLTNode* pos)
{assert(pos->next);assert(pos);SLTNode* per = pos->next;pos->next = per->next;free(per);}

在这里插入图片描述释放链表
在这里插入图片描述

http://www.yayakq.cn/news/680095/

相关文章:

  • 天津本地网站免费空间自带域名
  • 广东湛江网站建设大连网页
  • 温州网站制作优化wordpress注册邮件服务器
  • 做网站贷款三明网站制作
  • 网站上怎么做推广比较好呢wordpress 模版 cho s
  • 渭南 网站集约化建设汉中建设工程招投标
  • 中州建设有限公司网站个人做房产网站有哪些
  • 网站 展示板asp.net做的网站模板下载
  • 重庆做网站开发的公司有哪些网站开发视频教程迅雷下载
  • 做外贸公司网站wordpress图片库插件
  • 导航网站设计方案用dw做网站 主题是哪个
  • phpcms 调用网站名称一个网站 两个数据库
  • 装修房子的步骤流程seo外链群发工具
  • 怎么免费建立自己的网站步骤东莞网站建设的收费
  • 自己怎么做团购网站首页中国摄影网站有哪些
  • 网站支付链接怎么做简短干净三字公司起名
  • 自己做的网站提示不安全吗网站编写软件
  • 网站建设教程搭建芽嘱湖南岚鸿信赖seo基本步骤顺序
  • 深圳网站建设 找猴王网络大学生做网站赚钱流程
  • 做网站定位做网站做域名
  • 建站资源共享wordpress 无法将上传的文件移动至
  • 视频网站是怎么做权限管理的wordpress 菜单颜色
  • 重庆平台网站建设企业网站优化seo
  • 红酒商城网站建设方案书青岛网站设计模板
  • 如何构建成交型网站网络公司哪个最好
  • 自己如何做家政网站吉林seo排名公司
  • 网站托管的好处常用的网站建设技术有什么
  • 网站后台图片编辑器网站建设cms
  • 中山网站设计收费标准普通企业网站费用
  • 网站建设查看框架的源代码上海抖音推广公司