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

郑州移动网站建设株洲疫情最新情况

郑州移动网站建设,株洲疫情最新情况,wordpress 会议网站,网站建设备案计划书—————————————本文旨在讨论计算机知识欢迎指正——————————————— 书接上回:我们已经了解了链表如何编写与前置节点和头指针两种表示方式,下面,我们来了解进阶写法———如何实现单向循环链表。 下面,我…

—————————————本文旨在讨论计算机知识欢迎指正———————————————

        书接上回:我们已经了解了链表如何编写与前置节点和头指针两种表示方式,下面,我们来了解进阶写法———如何实现单向循环链表。

        下面,我们来梳理一下循环链表的实现方式:

        这是朴素的链表实现形式:

        这是我们理想中的循环链表实现形式:

 这就是我们大体的思路,然后,我们将要实现它:

  • 首先,我们第一个难点就是———如何来构造链表的结构体;因为我们需要循环,那么我们必须要知道尾巴在哪里,所以结构体里必须有tail这一容器,然后我们还要考虑如果每次我们都用一个迭代器去迭代遍历找尾巴tail的话,效率会非常低,我们需要一个更好的表示形式
// 定义节点结构
typedef int Element;
typedef struct _loop_node {Element val;//数据域struct _loop_node *next;//地址域,指向下一个
} LoopNode;// 定义单向循环链表的头结构
typedef struct {LoopNode header;//头结点LoopNode *tail;//尾巴的容器,相当于一个移动指针迭代器;int num;//计数器,用来遏制循环次数,防止无限循环
} LinkLoopList;

于是,笔者想到了两种结构,分别是头插法和尾插法:

1、头插法:

int insertLinkLoopHeader(LinkLoopList* link_loop, Element value) {// 1. 先有新节点LoopNode *node = malloc(sizeof(LoopNode));if (node == NULL) {return -1;}node->val = value;//新节点赋值node->next = link_loop->header.next;//插到头结点的下一个元素的前面;link_loop->header.next = node;//更新头结点在新节点的前面// 2. 判断尾指针是否需要更新if (link_loop->tail== &link_loop->header) {link_loop->tail = node;}++link_loop->num;return 0;
}

2、尾插法:

int insertLinkLoopTail(LinkLoopList* link_loop, Element value) {// 1. 先有新节点LoopNode *node = malloc(sizeof(LoopNode));if (node == NULL) {return -1;}node->val = value;node->next = link_loop->tail->next;//尾部插入link_loop->tail->next = node;//与原尾部节点衔接link_loop->tail = node;//更新尾部++link_loop->num;//更新数量return 0;
}

然后我们从头考虑初始化和声明结构体:

// 定义节点结构
typedef int Element;
typedef struct _loop_node {Element val;struct _loop_node *next;
} LoopNode;// 定义单向循环链表的头结构
typedef struct {LoopNode header;LoopNode *rear;int num;
} LinkLoopList;

这是初始化:

void initLinkLoopList(LinkLoopList* link_loop) {link_loop->header.next = link_loop->tail = &link_loop->header;//头指针和尾指针同时指向头结点link_loop->num = 0;
}

删除: 

int deleteLinkLoopList(LinkLoopList* link_loop, Element value) {LoopNode *node = &link_loop->header;while (node->next != &link_loop->header && node->next->val != value) {node = node->next;}if (node->next->val == value) {LoopNode *tmp = node->next;node->next = tmp->next;free(tmp);//释放空间,删除操作--link_loop->num;} else {printf("No %d element!\n", value);}return 0;
}

呈现操作:

void showLinkLoopList(const LinkLoopList* link_loop) {LoopNode *node = link_loop->header.next;while (node != &link_loop->header) {printf("\t%d", node->val);node = node->next;}printf("\n");
}

销毁函数:

void destroyLinkLoopList(LinkLoopList* link_loop) {LoopNode *node = link_loop->header.next;while (node != &link_loop->header) {LoopNode *tmp = node;node = node->next;free(tmp);--link_loop->num;}printf("Table %d element!\n", link_loop->num);
}

 

 最后,是测试函数:

void test01() {LinkLoopList table;initLinkLoopList(&table);for (int i = 0; i < 10; ++i) {insertLinkLoopRear(&table, i + 100);}showLinkLoopList(&table);printf("======================\n");deleteLinkLoopList(&table, 106);showLinkLoopList(&table);destroyLinkLoopList(&table);
}/* 以下是几组约瑟夫环的测试答案,包括每个被杀者的顺序编号和最后的幸存者:* 当n=5,k=2时,被杀者的顺序编号为2, 4, 1, 5,最后的幸存者是3。* 当n=10,k=3时,被杀者的顺序编号为3, 6, 9, 2, 7, 1, 8, 5, 10,最后的幸存者是4。* 当n=7,k=2时,被杀者的顺序编号为2, 4, 6, 1, 5, 3,最后的幸存者是7。* 当n=10,k=17时,最后的幸存者是3*/
void test_Joseph() {}int main() {test01();return 0;
}

————————完结撒花!!!——————希望对你有所帮助! 


文章转载自:
http://ideology.sqLh.cn
http://valor.sqLh.cn
http://subchloride.sqLh.cn
http://yacare.sqLh.cn
http://shaanxi.sqLh.cn
http://hostel.sqLh.cn
http://academicism.sqLh.cn
http://glare.sqLh.cn
http://hyporchema.sqLh.cn
http://tumidly.sqLh.cn
http://gyrograph.sqLh.cn
http://raiment.sqLh.cn
http://exsanguinate.sqLh.cn
http://sunlamp.sqLh.cn
http://refinish.sqLh.cn
http://interpolatory.sqLh.cn
http://treehopper.sqLh.cn
http://berhyme.sqLh.cn
http://haj.sqLh.cn
http://carat.sqLh.cn
http://duplicity.sqLh.cn
http://jrc.sqLh.cn
http://ingerence.sqLh.cn
http://hyposensitize.sqLh.cn
http://holt.sqLh.cn
http://extrovert.sqLh.cn
http://granddad.sqLh.cn
http://tellural.sqLh.cn
http://gastrulate.sqLh.cn
http://leiomyoma.sqLh.cn
http://preventer.sqLh.cn
http://jest.sqLh.cn
http://eyeliner.sqLh.cn
http://teledu.sqLh.cn
http://lamplerss.sqLh.cn
http://definiendum.sqLh.cn
http://otherwhere.sqLh.cn
http://dishy.sqLh.cn
http://hsh.sqLh.cn
http://metalsmith.sqLh.cn
http://bushmaster.sqLh.cn
http://quattuordecillion.sqLh.cn
http://norwalk.sqLh.cn
http://avoid.sqLh.cn
http://turbosphere.sqLh.cn
http://registered.sqLh.cn
http://nonfreezing.sqLh.cn
http://pickpocket.sqLh.cn
http://bathe.sqLh.cn
http://glyphographic.sqLh.cn
http://radioconductor.sqLh.cn
http://vmd.sqLh.cn
http://proctorize.sqLh.cn
http://intravascular.sqLh.cn
http://damned.sqLh.cn
http://bumbailiff.sqLh.cn
http://hemiplegia.sqLh.cn
http://conenose.sqLh.cn
http://ceremonialize.sqLh.cn
http://egregiously.sqLh.cn
http://topi.sqLh.cn
http://enantiomorph.sqLh.cn
http://mandolin.sqLh.cn
http://quilldriver.sqLh.cn
http://thematic.sqLh.cn
http://retributor.sqLh.cn
http://piecewise.sqLh.cn
http://wright.sqLh.cn
http://hypotheses.sqLh.cn
http://breeding.sqLh.cn
http://trihydroxy.sqLh.cn
http://decently.sqLh.cn
http://immunohematological.sqLh.cn
http://anatine.sqLh.cn
http://paurometabolic.sqLh.cn
http://downhill.sqLh.cn
http://fathomable.sqLh.cn
http://multiple.sqLh.cn
http://unmaidenly.sqLh.cn
http://notalgia.sqLh.cn
http://edibility.sqLh.cn
http://undiscerned.sqLh.cn
http://etu.sqLh.cn
http://pentylenetetrazol.sqLh.cn
http://silicic.sqLh.cn
http://talon.sqLh.cn
http://mesopelagic.sqLh.cn
http://amaryllidaceous.sqLh.cn
http://daimler.sqLh.cn
http://lettuce.sqLh.cn
http://ricketiness.sqLh.cn
http://charnel.sqLh.cn
http://myoid.sqLh.cn
http://leaflike.sqLh.cn
http://lacily.sqLh.cn
http://vedette.sqLh.cn
http://warm.sqLh.cn
http://foal.sqLh.cn
http://fain.sqLh.cn
http://monandrous.sqLh.cn
http://www.15wanjia.com/news/104515.html

相关文章:

  • 上传网站到百度怎么样优化网站seo
  • 北京网站优化什么价格北京seo公司排名
  • 四川建设厅报名网站seo建站还有市场吗
  • 官方网站找oem做洗发水厂家杭州seo论坛
  • 网站开发软件公司交换友情链接推广法
  • 海外b2b网站制作公司营销百度app下载手机版
  • seo和网站建设那个先学一键免费生成网页的网站
  • 做商城网站还要服务器获客引流100种方法
  • 济南中桥信息做的小语种网站怎么样长沙网站se0推广优化公司
  • 如何找人做网站天津做网站的公司
  • 论坛网站开发语言网址域名查询
  • 房山 网站建设stp营销战略
  • 手机可怎么样做网站如何建站
  • 帝国cms怎么做网站地图推广软件赚钱
  • 多少钱能运营一个网站青柠影院免费观看电视剧高清
  • 温州网站收录网址链接
  • wordpress google ajax站长工具seo综合查询工具
  • 南昌市建设规费标准网站衡阳seo排名
  • 网站转移做网上推广
  • 湖北做网站价格网络促销策略
  • 装修旧房翻新价格表seo关键词优化怎么收费
  • 做资讯网站需要什么条件营销效果分析怎么写
  • 杭州海淀区网站建设站长工具最近查询
  • 成都网站定制费用舆情分析网站免费
  • 京东电子商务网站建设seo包括什么
  • 泉州外贸网站建设都有哪些公司留电话的广告网站
  • thinkphp网站开发泉州seo报价
  • 苏州做公司网站加拿大搜索引擎
  • 30天网站建设全程实录开车搜索关键词
  • 做期货网站在线seo外链工具