void LinListSort(LinList<T> &L)
{
ListNode<T> *curr, *pre, *p, *q;
p = L.head->next; //原单链表
L.head->next = NULL; //新单链表
while(p != NULL)
{
curr = L.head->next;
pre = L.head;
while(curr != NULL && curr->data <= p->data)
{
pre = curr;
curr = curr->next;
}
q = p;
p = p->next;
q->next = pre->next;
pre->next = q;
}
}]
时间: 2024-11-06 23:43:50