问题遇到的现象和发生背景
问题相关代码,请勿粘贴截图
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);
}
运行结果及报错内容
我的解答思路和尝试过的方法
我想要达到的结果