# include<stdio.h>
# include<malloc.h>
# define NULL 0
# define LEN sizeof(struct student)
struct student
{long num;
float score;
struct student *next;
};
struct student *creat(void) ********创一个表输入的值是1101,65 1105,98 1124,95 0,0
{ int i; 但结果是1101,98 1105,95 1124,0
struct student *head;
struct student *p1,*p2;
p1=p2=(struct student *) malloc (LEN);
scanf("%ld,%f",&p1->num,&p1->score);
head=NULL;
i=0;
while(p1->num!=0)
{ i=i+1;
if(i==1)head=p1;
else p2->next=p1;
p2=p1;
p1=(struct student *)malloc(LEN);
scanf("%ld,%f",&p1->num,&p2->score);
}
p2->next=NULL;
return(head);
}
void print(struct student *head) \\\\输出一个表\\
{struct student *p;
p=head;
if(head!=NULL)
do
{printf("%ld,%f",p ->num,p ->score);
p=p->next;
} while(p!=NULL) ;
getch();
}
void main()
{struct student *creat();
void print(struct student *);
struct student *head;printf("\nInput the A records:\n");
head=creat();
print(head);
getch(); \\\\\\\最后说明问题是可以输出结果但不准确是
}