懒得放题目了,直接上答案,太难做了
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;
}
}
原文地址:https://www.cnblogs.com/Bunny-a/p/11671165.html
时间: 2024-11-07 16:42:47