void sort_link(Linklist * phead)///链表排序
{
Linklist * first = NULL;
Linklist * second = NULL;
Linklist * third = NULL;
Linklist * end = NULL;
Linklist * temp = NULL;
if(phead == NULL||phead->next == NULL)
{
puts(“无法排序\n”);
return;
}
while(phead->next != end)
{
for(first=phead,second=first->next,third=second->next;third!=end;first=second,
second=third,third=third->next)
{
if(second->number > third->number)
{
first->next = third;
second->next = third->next;
third->next = second;
temp = second;
second = third;
third = temp;
}
}
end = second;
}
}
2021-03-02
最新推荐文章于 2021-11-10 17:26:45 发布