c语言建立链表以及删除插入和修改的原代码要完整的

来源:百度知道 编辑:UC知道 时间:2024/06/01 11:52:29

main函数没写 你自己调用就ok了
#include<stdio.h>
#include<malloc.h>
#define len sizeof(struct student)
#define NULL 0
int n;
struct student
{
long number;
float score;
struct student *next;
};
struct student *creat(void)
{
struct student *p1,*p2,*head;
p1=p2=(struct student *)malloc(len);
scanf("%ld,%f",&p1->number,&p1->score);
head=NULL;
while(p1->number!=0)
{
n=n+1;
if(n==1) head=p1;
else p2->next=p1;
p2=p1;
p1=(struct student *)malloc(len);
scanf("%ld,%f",&p1->number,&p1->score);
}
p2->next=NULL;
return(head);
}
struct student *del(struct student *head,long number_1)
{
struct student *p1,*p2;
if(head==NULL) {printf("no list\n"); goto end;}
p1=head;
while((number_1!=p1->number)&&(p1->next!=NULL))
{
p2=p