数据结构链表

来源:百度知道 编辑:UC知道 时间:2024/07/08 04:29:50
#include<stdlib.h>
#include<conio.h>
#include<stdio.h>
#define NULL0
#define LEN sizeof(struct lnode)
struct lnode
{long num;
float score;
int date;
struct lnode*next;
}lnode;
int n;
struct lnode*creat(void)
{struct lnode*head;
struct lnode*p1,*p2;
n=0;
p1=p2=(struct lnode*)malloc(LEN);
scanf("%ld,%f",&p1->num,&p1->score);
head=NULL;
while(p1->num!=0)
{n=n+1;
if(n==1)head=p1;
else p2->next=p1;
p2=p1;
p1=(struct lnode*)malloc(LEN);
scanf("%ld,%f",&p1->num,&p1->score);
}
p2->next=NULL;
return(head);
}
struct lnode*insert(struct lnode*head,struct lnode*lnod)
{struct lnode*p0,*p1,*p2;
p1=head;
p0=lnod;
if(head==NULL)
{head=p0;p0->next=NULL;}
else
{while((p0->num>p1->num)&&(p1->next!=NULL))
{p2=p1;
p1=p1->next;}
if(p0-

#include <stdio.h>
#include<stdlib.h>
#include<conio.h>
#include<stdio.h>
#define NULL0
#define LEN sizeof(struct lnode)
struct lnode
{
long num;
float score;
int date;
struct lnode*next;
}lnode;
int n;
struct lnode*creat(void)
{
struct lnode*head;
struct lnode*p1,*p2;
n=0;
p1=p2=(struct lnode*)malloc(LEN);
scanf("%ld,%f",&p1->num,&p1->score);
head=NULL;
while(p1->num!=0)
{
n=n+1;
if(n==1)head=p1;
else p2->next=p1;
p2=p1;
p1=(struct lnode*)malloc(LEN);
scanf("%ld,%f",&p1->num,&p1->score);
}
p2->next=NULL;
return(head);
}
struct lnode *insert(struct lnode*head,struct lnode*lnod)
{
struct lnode*p0,*p1,*p2;
p1=head;
p0=lnod;
if(head==NULL)
{head=p0;p0->next