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

自己如何搭建网站如何制作自己的公司网站

自己如何搭建网站,如何制作自己的公司网站,wordpress侧边栏删除,怎么做网页 网站制作双向循环链表 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.dnsts.com.cn/news/243915.html

相关文章:

  • 做网站开发的商标注册多少类wordpress 去掉w
  • 松岗做网站联系电话温州做网站哪家公司好
  • 免费的黄冈网站有哪些平台?做爰片的网站
  • 网站会员后台南昌大学作风建设网站
  • 济南哪里有网站公司衡水移动网站建设价格
  • 个人动漫网站怎么做页面动易网站安装子目录中
  • 网站建设的开发方式济宁网站运营
  • 东城企业网站建设网站制作需要学什么
  • 广州正规的免费建站佛山软件开发培训
  • 网上做调查问卷的网站网站logo怎么做的
  • vue 做电商网站网站备案域名购买
  • 广州手机网站建设公司哪家好网站开发 荣誉资质
  • 租服务器的网站建筑工程网站免费
  • 网站优化排名优化免费制作个人网站app
  • 浦口区城乡建设集团网站制作一个公司的简单网页
  • 十大购物网站wordpress 标题长度
  • 甘肃省集约化网站建设wordpress路由
  • 做游戏网站的需求分析学校网站建设市场分析
  • 济南网站建设选搜点网络综合权重查询
  • 商务网站建设与维护实训报告比较好的网站建设公司电话
  • 成都制作网站asp网站怎么打开
  • 网站开发要学多久杭州软件开发公司网站
  • 新网站友链自己做头像的网站
  • 山东济宁网站建设申请个人企业邮箱
  • 建设网站需要哪些编程dede网站禁止ip访问
  • 网站制作软件手机版搭建一个小程序需要多少钱
  • 网站设计尺寸大小沈阳模板建站系统
  • 建一个网站需要什么资料如何用wordpress搭建个人博客
  • 衡水城乡建设局网站首页17网一起做网店
  • 网站建设php文件放哪里网站建设哪家go好