/*归并法:用于合并两个链表*/ /* * SCs in different cases * author: Whywait */ typedef struct node { Elemtype data; struct node* next; } Lnode; /*case ONE*/ Lnode* merge1(Linklist& LA, Linklist& LB) { // merge two sorted Singly linked lists // LA, LB and the return one ( LC ) all have a head node // all the linklist are sorted in the same way: increasing or decreasing // we assume that all the slists are sorted in an increasing order // KEY: insert in the tail Lnode* LC = (Lnode*)malloc(sizeof(Lnode)); LC->next = NULL; Lnode* pa = LA->next, * pb = LB->next, * pc = LC; while (pa && pb) { if (pa->data < pb->data) { pc->next = pa; pa = pa->next; } else { pc->next = pb; pb = pb->next; } pc = pc->next; } if (pa) pc->next = pa; if (pb) pc->next = pb; return LC; } /*case TWO*/ Lnode* merge2(Linklist& LA, Linklist& LB) { // merge two sorted Singly linked lists // LA, LB and the return one ( LC ) all have a head node // all the linklist are sorted not in the same way: // LA and LB are the same, but LC just the other way // we assume that LA and LB are sorted in an increasing order // KEY: insert in the front Lnode* LC = (Lnode*)malloc(sizeof(Lnode)); LC->next = NULL; Lnode* pa = LA->next, * pb = LB->next; while (pa && pb) { Lnode* temp = NULL; if (pa->data < pb->data) { temp = pa->next; pa->next = LC->next; LC->next = pa; pa = temp; } else { temp = pb->next; pb->next = LC->next; LC->next = pb; pb = temp; } } if (pa) pc->next = pa; if (pb) pc->next = pb; return LC; }
本网页所有视频内容由 imoviebox边看边下-网页视频下载, iurlBox网页地址收藏管理器 下载并得到。
ImovieBox网页视频下载器 下载地址: ImovieBox网页视频下载器-最新版本下载
本文章由: imapbox邮箱云存储,邮箱网盘,ImageBox 图片批量下载器,网页图片批量下载专家,网页图片批量下载器,获取到文章图片,imoviebox网页视频批量下载器,下载视频内容,为您提供.
阅读和此文章类似的: 全球云计算