最近刚好学数据结构写了这么一个代码!你自己看看,觉得那个好!
void SortList(LIST **head)
{
if(head == NULL)
{
printf("Linked list does not exist!\n");
exit(OVERFLOW);
}
int temp;
LIST *p = (*head)->next;
LIST *pr = (*head)->next;
while(pr != NULL)
{
p = p->next;
while(p != NULL)
{
if(pr->data > p->data)
{
temp = pr->data;
pr->data = p->data;
p->data = temp;
}
p = p->next;
}
pr = pr->next;
p = pr;
}
}