一个c语言题,用单向链表做的,帮忙改改错

来源:百度知道 编辑:UC知道 时间:2024/06/30 21:01:47
#include<stdio.h>
#include<stdlib.h>
#define NULL 0
struct student
{
int Num;
char Name[16];
float Score;
struct student *next;
};
struct student *creat()
{
struct student *head,*tail,*p;
int Num;
int size=sizeof(struct student);
head=tail=NULL;
scanf("%d",&Num);
while(Num!=0)
{p=(struct student *)malloc(size);
p->Num=Num;
printf("\ninput Name and Score:\n");
scanf("%s%f",p->Name,&p->Score);
p->next=NUll;
if(head==NULL)
head=p;
else
tail->next=p;
tail=p;
scanf("%d",&Num);
}
return head;
}
void print(struct student *head)
{
struct student *p=head;
while(p!=NULL)
{printf("%d\t%s\t%f",p->Num,p->Name,p->Score);
p=p->next;
}
}
struct student *belong

#include<stdio.h>
#include<stdlib.h>
#include <string.h>
#define NULL 0

typedef struct student
{
int Num;
char Name[16];
float Score;
struct student *next;
}Student;

Student *creat();
Student *insert(Student*, int, char*, float);
int belongTo(Student*, int);
Student *delete1(Student*,int);
void print(Student*);

struct student *creat()
{
struct student *head,*tail,*p;
int Num;
int size= sizeof(struct student);
printf("\nin put the num:");

head = tail = NULL;
scanf("%d",&Num);
while(Num != 0)
{
p=(struct student *)malloc(size);
p->Num = Num;
printf("\ninput Name and Score:\n");
scanf("%s%f", p->Name, &p->Score);
p->next=NULL;
if(head==NULL) head=p;
else tail->next=p; <