请教关于链表的排序?求找错!!
程序代码:
typedef struct st { char name[50]; int score; struct st *pnext; }SC, *PSC; /*排序函数*、 void sort(PSC phead) { PSC p, s, t; int i, n, j; if ((p=phead->pnext)==NULL||(s=p->pnext)==NULL) { exit(0); } t = phead; for (i=1; i<cnt; i++) { p = phead->pnext; t = phead; for (j=0; j<cnt-i; j++) { s = p->pnext; if (p->score > s->score) { t->pnext = s; p->pnext = s->pnext; s->pnext = p; s = p; p = t->pnext; } t = p; p = s; } } p = phead; while(p!= NULL) { printf("\t\t\t%s\t\t%d\n", p->name, p->score); p = p->pnext; } system("pause"); }