如何用递归算法实现2个有序链表的合并?

stu* Combine(stu* head1, stu* head2)
{

if (head1 == NULL)
{
    return head2;
}
if (head2 == NULL)
{
    return head1;
}
stu* head = NULL;
if (head1->m_score < head2->m_score)
{
    head = head2;
    head->next = Combine(head1,head2->next);
}
else
{
    head = head1;
    head->next = Combine(head1->next, head2);
}
return head;

}

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐