單鏈表的插入排序
stu *view_sort_math(stu *head)
{
struct student *first;
struct student *t;
struct student *p;
struct student *q;
first = head->next;
head->next = NULL;
while (first != NULL)
{
for (t = first, q = head; ((q != NULL) && (q->chinese > t->chinese)); p = q, q = q->next);
first = first->next;
if (q == head)
{
head = t;
}
else
{
p->next = t;
}
t->next = q;
}
return head;
}
{
struct student *first;
struct student *t;
struct student *p;
struct student *q;
first = head->next;
head->next = NULL;
while (first != NULL)
{
for (t = first, q = head; ((q != NULL) && (q->chinese > t->chinese)); p = q, q = q->next);
first = first->next;
if (q == head)
{
head = t;
}
else
{
p->next = t;
}
t->next = q;
}
return head;
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.