您的位置:首页 > 其它

把元素递增的线性表La和Lb合并为Lc,且Lc的中的元素递减排列,使用原空间

2007-12-17 12:22 543 查看
void Reverse_merge(pLinkList la,pLinkList lb,struct LinkList ** lc)

{

pLinkList current = NULL;

while ( la && lb )

{

if ( la->value < lb->value )

{

*lc = la;

la = la->next;

(*lc)->next = current;

current = *lc;

}

else

{

*lc = lb;

lb = lb->next;

(*lc)->next = current;

current = *lc;

}

}

while (la)

{

*lc = la;

la = la->next;

(*lc)->next = current;

current = *lc;

}

while (lb)

{

*lc = lb;

lb = lb->next;

(*lc)->next = current;

current = *lc;

}

}

类似于归并排序中的一种合并方法
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐