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

自己如何搭建网站网站关键词排名优化推广软件

自己如何搭建网站,网站关键词排名优化推广软件,免费网站模板之家,网站后台搭建教程双向循环链表 1、带头双向循环链表概念2、带头双向循环链表的优势3、带头双向循环链表的实现3.1、头文件包含和结构定义3.2、创建新结点3.3、打印3.4、初始化3.5、销毁3.6、尾插3.7、头插3.8、头删3.9、尾删3.10、查找3.11、在pos之前插入3.12、删除pos位置3.13、判断是否为空3… 双向循环链表 1、带头双向循环链表概念2、带头双向循环链表的优势3、带头双向循环链表的实现3.1、头文件包含和结构定义3.2、创建新结点3.3、打印3.4、初始化3.5、销毁3.6、尾插3.7、头插3.8、头删3.9、尾删3.10、查找3.11、在pos之前插入3.12、删除pos位置3.13、判断是否为空3.14、计算大小 4、代码汇总总结 1、带头双向循环链表概念 概念带头双向循环链表是一种特殊类型的链表它由一系列节点组成每个 节点包含一个数据域和两个指针域第一个结点不存储有效数据。其中一个指 针指向下一个节点另一个指针指向前一个节点。在带头双向循环链表中首 节点的前一个节点是尾节点尾节点的下一个节点是首节点形成一个闭环。2、带头双向循环链表的优势 1.高效遍历由于带头双向循环链表可以双向遍历因此可以在O(1)时间内访问任何节点。 2.内存高效与双向链表相比带头双向循环链表不需要额外的内存来存储头部节点。 3.插入和删除操作高效在带头双向循环链表中插入和删除节点时只需调整指针即可无需移动大量数据。 3、带头双向循环链表的实现 实现一个带头双向循环链表首先得创建一个工程。(下图为vs 2022) List.h带头双向循环链表的类型定义、接口函数声明、引用的头文件 List.c带头双向循环链表接口函数的实现 test.c 主函数、测试顺序表各个接口功能 以下是List.h的代码。 #define _CRT_SECURE_NO_WARNINGS #includestdio.h #includestdlib.h #includeassert.h #includestdbool.h typedef int LTDataType; typedef struct ListNode {LTDataType data;struct ListNode* next;struct ListNode* prev; }ListNode;//双向链表打印 void ListPrint(ListNode* phead); //双向链表初始化 ListNode* ListInit(); //双向链表销毁 void ListDestory(ListNode* phead); //双向链表尾插 void ListPushBack(ListNode* phead, LTDataType x); //头插 void ListPushFront(ListNode* phead, LTDataType x); //头删 void ListPopFront(ListNode* phead); //尾删 void ListPopBack(ListNode* phead); //查找 ListNode* ListFind(ListNode* phead, LTDataType x); //在pos之前插入 void ListInsert(ListNode* pos, LTDataType x); //删除pos位置 void ListErase(ListNode* pos); //判断是否为空 bool ListEmpty(ListNode* phead); //计算大小 int ListSize(ListNode* phead);3.1、头文件包含和结构定义 以下是实现双向循环链表可能用到的头文件。 #includestdio.h #includestdlib.h #includeassert.h #includestdbool.h以下是博主创建的双向循环链表的结构可以根据自己的喜好创建喔。 建议创建结构时最好能通俗易懂最好不用拼音创建。 typedef int LTDataType;//定义数据类型可以根据需要更改 typedef struct ListNode {LTDataType data; //数据域 存储数据struct ListNode* next;//指针域 存储指向下一个结点的指针struct ListNode* prev;//指针域 存储指向前一个结点的指针 }ListNode;3.2、创建新结点 为什么先创建新结点而不是初始化呢因为当前链表为带头的链表初始化时需要创建结点所以就先封装创建结点函数。 ListNode* BuyList(LTDataType x) {ListNode* newnode (ListNode*)malloc(sizeof(ListNode));if (newnode NULL){printf(malloc fail\n);exit(-1);}newnode-data x;newnode-next NULL;newnode-prev NULL;return newnode; }3.3、打印 void ListPrint(ListNode* phead) {assert(phead);ListNode* cur phead-next;while (cur ! phead){printf(%d , cur-data);cur cur-next;}printf(\n); }3.4、初始化 ListNode* ListInit() {ListNode* phead BuyList(0);phead-next phead;//构成循环phead-prev phead;//构成循环return phead; }3.5、销毁 void ListDestory(ListNode* phead) {assert(phead);ListNode* cur phead-next;while (cur ! phead){ListNode* next cur-next;free(cur);cur next;}free(phead);phead NULL;//养成好习惯释放之后手动置为NULL }3.6、尾插 void ListPushBack(ListNode* phead, LTDataType x) {assert(phead);//1.创建结点ListNode* newnode BuyList(x);ListNode* tail phead-prev;//先找到尾结点//2.链接nexttail-next newnode;newnode-prev tail;//3.链接prevnewnode-next phead;phead-prev newnode;}尾插测试 建议养成有初始化函数就有销毁函数的习惯。 3.7、头插 void ListPushFront(ListNode* phead, LTDataType x) {assert(phead);ListNode* newnode BuyList(x);ListNode* first phead-next;phead-next newnode;newnode-prev phead;newnode-next first;first-prev newnode; }头插测试 3.8、头删 void ListPopFront(ListNode* phead) {assert(phead);assert(phead-next ! phead);//没有数据则报错ListNode* first phead-next;ListNode* second first-next;phead-next second;second-prev phead;free(first);first NULL; }测试头删 3.9、尾删 void ListPopBack(ListNode* phead) {assert(phead);assert(phead-next ! phead);ListNode* tail phead-prev;ListNode* prev tail-prev;prev-next phead;phead-prev prev;free(tail);tail NULL; }尾删测试 3.10、查找 思想遍历一遍链表如果该结点的data等于x则返回该结点的地址遍历一遍没有找到则返回NULL跟后面在pos位置插入函数结合起来用。 ListNode* ListFind(ListNode* phead, LTDataType x) {assert(phead);ListNode* cur phead-next;while (cur ! phead){if (cur-data x){return cur;}cur cur-next;}return NULL; }3.11、在pos之前插入 跟头插尾插思想差不多可以自己画图理解理解喔如果有不理解的可以私信博主喔这里就没有画图啦 void ListInsert(ListNode* pos, LTDataType x) {assert(pos);ListNode* newnode BuyList(x);ListNode* prev pos-prev;prev-next newnode;newnode-prev prev;newnode-next pos;pos-prev newnode; }测试 3.12、删除pos位置 void ListErase(ListNode* pos) {assert(pos);ListNode* prev pos-prev;ListNode* next pos-next;prev-next pos-next;next-prev prev; }3.13、判断是否为空 bool ListEmpty(ListNode* phead) {assert(phead);return phead-next phead;//相等则为真不相等则为假 }3.14、计算大小 思想创建一个size变量从头结点的下一个结点遍历链表不等于头结点则将size。 int ListSize(ListNode* phead) {assert(phead);ListNode* cur phead-next;int size 0;while (cur ! phead){size;cur cur-next;}return size; }测试 4、代码汇总 以下是SList.c的代码 //创建结点 ListNode* BuyList(LTDataType x) {ListNode* newnode (ListNode*)malloc(sizeof(ListNode));if (newnode NULL){printf(malloc fail\n);exit(-1);}newnode-data x;newnode-next NULL;newnode-prev NULL;return newnode; } //打印 void ListPrint(ListNode* phead) {assert(phead);ListNode* cur phead-next;while (cur ! phead){printf(%d , cur-data);cur cur-next;}printf(\n); } //初始化 ListNode* ListInit() {ListNode* phead BuyList(0);phead-next phead;//构成循环phead-prev phead;//构成循环return phead; } //销毁 void ListDestory(ListNode* phead) {assert(phead);ListNode* cur phead-next;while (cur ! phead){ListNode* next cur-next;free(cur);cur next;}free(phead);phead NULL;//养成好习惯释放之后手动置为NULL } //尾插 void ListPushBack(ListNode* phead, LTDataType x) {assert(phead);ListNode* newnode BuyList(x);ListNode* tail phead-prev;tail-next newnode;newnode-prev tail;newnode-next phead;phead-prev newnode; } //头插 void ListPushFront(ListNode* phead, LTDataType x) {assert(phead);ListNode* newnode BuyList(x);ListNode* first phead-next;phead-next newnode;newnode-prev phead;newnode-next first;first-prev newnode;} //头删 void ListPopFront(ListNode* phead) {assert(phead);assert(phead-next ! phead);ListNode* first phead-next;ListNode* second first-next;phead-next second;second-prev phead;free(first);first NULL; } //尾删 void ListPopBack(ListNode* phead) {assert(phead);assert(phead-next ! phead);ListNode* tail phead-prev;ListNode* prev tail-prev;prev-next phead;phead-prev prev;free(tail);tail NULL; } //查找元素为X的地址 ListNode* ListFind(ListNode* phead, LTDataType x) {assert(phead);ListNode* cur phead-next;while (cur ! phead){if (cur-data x){return cur;}cur cur-next;}return NULL; } //在pos之前插入 void ListInsert(ListNode* pos, LTDataType x) {assert(pos);ListNode* newnode BuyList(x);ListNode* prev pos-prev;prev-next newnode;newnode-prev prev;newnode-next pos;pos-prev newnode; } //删除pos位置 void ListErase(ListNode* pos) {assert(pos);ListNode* prev pos-prev;ListNode* next pos-next;prev-next pos-next;next-prev prev; } //判断是否为空 bool ListEmpty(ListNode* phead) {assert(phead);//1.//if (phead-next phead)//{// return true;//}//else//{// return false;//}//2.return phead-next phead; } //获取有效数据个数 int ListSize(ListNode* phead) {assert(phead);ListNode* cur phead-next;int size 0;while (cur ! phead){size;cur cur-next;}return size; }总结 本篇博客就结束啦谢谢大家的观看如果公主少年们有好的建议可以留言喔谢谢大家啦
http://www.hkea.cn/news/14351910/

相关文章:

  • 上海网站设计联系方式网站ico图标 代码
  • 网站建设swot网站制作好了怎么上传
  • 中国建设培训网站查询系统怎么做自己网站里的资讯
  • 有没有做软件的外包网站wordpress uncode
  • 怎么介绍自己做的电影网站网站建设推广刘贺稳1
  • 网站做宣传的免费渠道有那种wordpress小说网站
  • 徐州网站制作费用在线做漫画的网站
  • 网站建设文编怎么给甲方做网站备案
  • 罗湖网站制作多少钱智慧团建官网登录口
  • 上传文件到网站根目录济南网络运营公司
  • php 网站后台管理系统软件开发包括网站开发吗
  • 湖南网站建设360o深圳公司网站建设公司
  • 合肥网站建设推荐 晨飞网络天津开发区建设工程管理中心网站
  • 模板网站建设全过程推广关键词怎么设置
  • 深圳建筑设计平台网站网站建设公司的服务公司
  • 门户网站建设整改措施昆明个人网站建设平台
  • 西安找建网站公司友链交换有什么作用
  • 广西南宁市有公司网站设计汕头做网站优化公司
  • 旅游网站建设首选赢旅动力中国互联网上网服务行业协会
  • dw 做的网站能用吗php大型网站设计
  • 云南网站设计哪家专业珠海建设工程交易中心网站
  • 商务网站建设期末作业我的网站怎么不能搜索
  • 京东云服务器怎么做网站公众号开发用什么语言
  • 品牌策划网站建设二手房出售
  • 宝安区住房和建设局网站网页设计的基础知识
  • 郑州手机网站开发wordpress 发音
  • 博客可以做网站收录用的吗网站建设实验代码
  • 成都 企业网站建设公司网站建设源码是什么
  • 专门做书单的网站网页制作与网站建设宝典(第2版)
  • vs做asp网站流程佛山网站建设天博