资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

合并两个已序单链表

// 合并两个已序单链表

成都创新互联公司-专业网站定制、快速模板网站建设、高性价比天门网站开发、企业建站全套包干低至880元,成熟完善的模板库,直接使用。一站式天门网站制作公司更省心,省钱,快速模板网站建设找我们,业务覆盖天门地区。费用合理售后完善,十多年实体公司更值得信赖。

PSListNode MergeList(PSListNode pL1, PSListNode pL2)

{

                 PSListNode pNewHead = NULL ;

                 PSListNode pL1Node = pL1 ;

                 PSListNode pL2N0de = pL2 ;

                 PSListNode pNode = NULL ;

                 PSListNode pTailNode = NULL ;

                 if (pL1 == NULL)

                {

                                 return pL2 ;

                }

                 if (pL2 == NULL)

                {

                                 return pL1 ;

                }

                 if (pL1Node->data > pL2N0de->data)

                {

                                pNode = pL2N0de;

                                pL2N0de = pL2N0de->pNext;

                }

                 else

                {

                                pNode = pL1Node;

                                pL1Node = pL1Node->pNext;

                }

                pNewHead = pNode;

                pTailNode = pNode;

                 while (pL1Node&&pL2N0de)

                {

                                 if (pL1Node->data > pL2N0de->data)

                                {

                                                pNode = pL2N0de;

                                                pL2N0de = pL2N0de->pNext;

                                }

                                 else

                                {

                                                pNode = pL1Node;

                                                pL1Node = pL1Node->pNext;

                                }

                                pTailNode->pNext = pNode;

                                pTailNode = pTailNode->pNext;

                }

                 if (pL1Node == NULL )

                {

                                pTailNode->pNext = pL2N0de;

                }

                 else

                {

                                pTailNode->pNext = pL1Node;

                }

                 return pNewHead;

}


void Print(PSListNode pHead)

{

                 PSListNode pCurNode = pHead ;

                 while (pCurNode)

                {

                                printf( "%d->", pCurNode->data);

                                pCurNode = pCurNode->pNext;

                }

                printf( "NULL\n");

}


新闻标题:合并两个已序单链表
转载来于:http://cdkjz.cn/article/gsoopo.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

大客户专线   成都:13518219792   座机:028-86922220