typedef struct Student //学生成绩结构体
{
char name[50];
int xuehao;
double score[N];
int ranking;
}student;
typedef struct Node //链表结点
{
student stu;
struct Node* next;
}Node, * PointNode;
void Quicksort(PointNode& tf, PointNode& p)//tf是链表头结点 p是链表尾结点
{
PointNode i = tf;
PointNode n=tf;
PointNode m=tf;
PointNode j = p;
student t, temp;
if (i == j)
return;
temp = i->stu;
while (i != j)
{
while (j->stu.ranking >= temp.ranking && i != j)
{
for (n = tf; n != j; n = n->next)
m = n;
j = m;
}
while (i->stu.ranking <= temp.ranking && i != j)
{
i = i->next;
}
if (i != j)
{
t = i->stu;
i->stu = j->stu;
j->stu = t;
}
}
tf->stu = i->stu;
i->stu = temp;
for (n = tf; n != i; n = n->next)
m = n;
Quicksort(tf, m);
Quicksort(i->next, p);
}
你要加个判断 n!=NULL
for (n = tf; n!=NULL && n != j; n = n->next)
您好,我是有问必答小助手,您的问题已经有小伙伴帮您解答,感谢您对有问必答的支持与关注!