求C语言 顺序表 单链表 的删除和插入 原代码

来源:百度知道 编辑:UC知道 时间:2024/05/21 10:12:08
求C语言 顺序表 单链表 的删除和插入 原代码

以下是插入 删除 建立 和打印
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!=NU