动态链表的输入和输出函数 如何建立连击?
void print (struct student *head) {
struct student * p;
printf("\nNow,These %d records are:\n",n);
p=head;
if(head!=NULL)
do {
printf("%ld %5.lf\n",p -> num,p -> score); 这是链表的输出
p=p -> next; }while(p!=NULL);
}
我想问是 他们怎么构成联系?链表的输出函数怎么找到链表头的?
struct student *creat(void)
{ struct student *head; struct student*p1,*p2; 这是链表的构建
n=0; p1=p2=(struct student*) malloc(LEN);
scanf("%1d,%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 student*)malloc(LEN);
scanf("%1d,%f",&p1->num,&p1->score);
}
p2->next=NULL;
return(head);
}