scanf("%d%s",&p1->num,p1->name);
head=NULL;
while (p1->num != 0)
{
n=n + 1;
if(n==1)
head=p1;
else
p2->next=p1;
p2=p1;
p1=(struct student * )malloc(LEN);
scanf("%d%s",&p1->num,p1->name);
}
p2->next=NULL;
return head;
}
void print(struct student * head)
{
struct student * p;
printf("\n Now, These %d records are: \n",n);
p=head;
if (head != NULL)
do
{
printf("%d,%s\n",p->num,p->name );
p=p->next;
}
while (p != NULL);
}
struct student * insert(struct student * head,struct student * stud)
{
struct student * p0, * p1, * p2;
p1=head;
p0=stud;
if (head==NULL)
{
head=p0;
p0->next=NULL;
}
else
{
评论0
最新资源