实验11-2-5-链表 链表拼接 (20 分)

Posted bunny-a

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了实验11-2-5-链表 链表拼接 (20 分)相关的知识,希望对你有一定的参考价值。

懒得放题目了,直接上答案,太难做了
struct ListNode* mergelists(struct ListNode* list1, struct ListNode* list2)
{
struct ListNode* head, * tmp, * t;
head = (struct ListNode)malloc(sizeof(struct ListNode));
head->next = list1;
tmp = head;
if (list1 == NULL && list2 == NULL)
{
return list1;
}
else {
while (tmp->next)
{
tmp = tmp->next;
}
tmp->next = list2;
int flag = 1;
for (flag;flag < 1000;flag++)
{
tmp = head;
while (tmp->next->next)
{
if (tmp->next->data > tmp->next->next->data)
{
t = tmp->next->next;
tmp->next->next = t->next;
t->next = tmp->next;
tmp->next = t;
}
tmp = tmp->next;
}
}
return head->next;
}
}

以上是关于实验11-2-5-链表 链表拼接 (20 分)的主要内容,如果未能解决你的问题,请参考以下文章

PTA实验 链表拼接 (20point(s))

HBU-DS实验题解目录(断更博主不{月}定{考}期{周}回归)

基础实验3-2.3 共享后缀的链表 (25分)

[PTA]实验11-2-6 奇数值结点链表

[PTA]实验11-2-1 建立学生信息链表

基础实验3-2.2 单链表分段逆转 (25分)--单链表