0条评论
还没有人评论过~
不知道为什么经过排序后打出来的成绩单就变成两项了,请大佬们帮忙看看
//对成绩进行排序
struct stu *rank_info(struct stu *head)
{
struct stu *p, *q, *r, *o, *s, *t;
int n = 1, i;
while(n != 0)
{
n = 0;
for (p = head; p->next != NULL; o = p, p = q)
{
q = p->next;
r = q->next;
if (p->grades.g < q->grades.g)
{
++n;
if (p = head) head = q;
else o->next = q;
q->next = p;
p->next = r;
s = p;
p = q;
q = s;
}
}
}
//添加学生排名信息
for (t = head, i = 1; t != NULL; t = t->next)
{
t->grades.rank = i++;
printf("%s", t->name);
}
return head;
}
if (p = head) 应该写成 if (p == head)