看看这个C语言的链表排序哪错了

来源:百度知道 编辑:UC知道 时间:2024/06/14 06:18:34
#include <stdio.h>
#include <malloc.h>
struct student
{
char name[20];
int score;
struct student *next;
};

struct student *head, *s;

struct student *creat()
{
int n=0;
struct student *p1, *p2;
p2 = p1 = (struct student *)malloc(sizeof(student));
while(scanf("%s%d",p1->name,&p1->score),p1->score!=0)
{
n++;
if (n == 1) head=p1;
else p2->next = p1;
p2 = p1;
p1 = (student *)malloc(sizeof(student));
}
p2->next = NULL;
free(p1);
return head;
}

struct student *paixu(student *head)
{
int m = 0;
struct student *p1, *p2,*before,*tail1,*small,*tail2,*k;
s = NULL; //新链表的头指针
tail2=tail1=(struct student *)malloc(sizeof(student));
while(head!= NULL) //当原链表的元素全部移到s中去,结束排列过程
{ <

#include <stdio.h>
#include <malloc.h>
#include <stdlib.h>
struct student
{
char name[20];
int score;
struct student *next;
};

struct student *head, *s;

struct student *creat()
{
int n=0;
struct student *p1, *p2;
p2 = p1 = (struct student *)malloc(sizeof(struct student));
while(scanf("%s%d",p1->name,&p1->score),p1->score!=0)
{
n++;
if (n == 1) head=p1;
else p2->next = p1;
p2 = p1;
p1 = (struct student *)malloc(sizeof(struct student));
}
p2->next = NULL;
free(p1);
return head;
}

int paixu(struct student *score)
{
int m = 0;
struct student *p1, *p2,*before,*tail1,*small,*tail2,*k;
s = NULL; //新链表的头指针
tail2=tail1=(struct student *)malloc(sizeof(struct student));
while(head!= NULL) //当原链表的元素全部移到s中去,结束排列过程
{
k = NULL;