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

肥乡网站建设青岛手机网站设计公司

肥乡网站建设,青岛手机网站设计公司,排版漂亮的网站,深圳做网站哪个好合并有序链表 图解代码如下 图解 虽然很复杂,但能够很好的理解怎么使用链表,以及对链表的指针类理解 代码如下 Node* merge_list_two_pointer(List& list1, List& list2) {Node* new_head1 list1.head;Node* new_head2 list2.head;Node* s…

合并有序链表

  • 图解
    • 代码如下

图解

虽然很复杂,但能够很好的理解怎么使用链表,以及对链表的指针类理解
在这里插入图片描述

代码如下

Node* merge_list_two_pointer(List& list1, List& list2)
{Node* new_head1 = list1.head;Node* new_head2 = list2.head;Node* sentinel1 = list1.head;Node* sentinel2 = list2.head;Node* temp_head1 = NULL;Node* temp_head2 = NULL;int flage = 1;//因为下面是<=,所以以list2优先为空if (new_head1->data >= new_head2->data){flage = 2;}while (new_head1 != NULL && new_head2 != NULL){while (list1.head != NULL && list1.head->data < list2.head->data){temp_head1 = list1.head;list1.head = list1.head->next;}//正常两个有序列表,上面为空,//456,123456789if (list1.head == NULL && flage == 2){temp_head1->next = list2.head;return sentinel2;}//特殊情况列表,全大//123,456if (list1.head == NULL){temp_head1->next = new_head2;return sentinel1;}if (temp_head1 != NULL){temp_head1->next = new_head2;}while (list2.head != NULL && list2.head->data <= list1.head->data){temp_head2 = list2.head;list2.head = list2.head->next;}//正常两个有序列表,下面为空//123456789,456if (list2.head == NULL && flage == 1){temp_head2->next = list2.head;return sentinel1;}//特殊情况列表也就是,全小//456,123if (list2.head == NULL){//防止89,89这种类型链表跑空temp_head2->next = list1.head;return sentinel2;}//这里不需要判断这个为空。如果为空,则说明已经到达链表尾部temp_head2->next = list1.head;new_head1 = list1.head;new_head2 = list2.head;}
}
http://www.yayakq.cn/news/22063/

相关文章:

  • 环保公司网站建设内容免版权费自建网站
  • 福建做网站公司注册劳务公司流程和费用
  • 已经备案的网站新增ip怎么做有哪些网站是html5的
  • 网站开发专业毕业设计网站建设 盈科
  • 宁夏住宅建设发展公司网站公司进门logo形象墙
  • 网站生成word程序员wordpress插件
  • 知名的咨询行业网站制作婚纱礼服外贸网站
  • 很多搜索词网站怎样做东莞企业网站找谁
  • 做网站需要服务器吗注册网站会不会有风险
  • 东阳网站建设公司摄影网站开发背景怎么写
  • 汕头站扩建后比哪个站大网上商城网站名称
  • 做油漆稀料用哪个网站wordpress服务
  • 合肥制作网站的公司简介提供企业门户网站建设
  • 营销型网站展示中学生做的安全作业网站
  • 临夏网站建设公司wordpress下拉菜单的阴影怎么改
  • 网站建设捌金手指下拉十一临沂网站制作专业
  • 网站用图要怎么做北京做手机网站建设
  • 广州网站制作怎么做seo的中文意思是什么
  • 做网站项目实例网站设计与建设考试
  • 新网 网站建立聊城集团网站建设报价
  • 宜城市城乡建设局网站上线了建站怎么收费
  • 网站 锚点链接怎么做湛江高端网站建设
  • 福建两学一做网站厦门网站开发平台
  • 网站开发的主要工作做网站去除视频广告
  • 做外贸怎样浏览国外网站wordpress 教程主题
  • 网站注阿里云备案 网站备案域名
  • 肇庆网站开发公司建网站服务器是什么东西
  • 温州网站制作公司国家商标注册官网
  • 贵阳公司网页网站建设网站模板免费下载
  • 移动网站用什么建设网络seo哈尔滨