c语言链表排序出错,直接排序初学者求大神
void sort(LinkList *list){
LinkList *p, *q;
list = list->next;
for (p = list; p ->next != NULL; p = p->next){
int k = p->score;
for (q = p->next; q != NULL; q = q->next) {
if (k < q->score) {
k = q->score;
}
if (q->next == NULL) {
q->score = p->score;
p->score = k;
}
}
}
}
LinkList *p, *q;
list = list->next;
for (p = list; p ->next != NULL; p = p->next){
int k = p->score;
for (q = p->next; q != NULL; q = q->next) {
if (k < q->score) {
k = q->score;
}
if (q->next == NULL) {
q->score = p->score;
p->score = k;
}
}
}
}