#include#include #define zjr sizeof(struct student) struct student{ int num; char name[20]; float cj[3]; struct student*next; }; int n; struct student *fgo() { struct student *head,*p1,*p2; p1=p2=(struct student*)malloc(zjr); head=NULL; scanf("%d %s %f %f %f",&p1->num,p1->name,&p1->cj[0],&p1->cj[1],&p1->cj[2]); while(p1->num!=0) { n+=1; if(n==1) head=p1; else p2->next=p1; p2=p1; p1=(struct student*)malloc(zjr); scanf("%d %s %f %f %f",&p1->num,p1->name,&p1->cj[0],&p1->cj[1],&p1->cj[2]); } p2=NULL; return head; } int main() { struct student *p,*s; p=fgo(); s=p; printf("输出链表n"); if(p!=NULL) do{ printf("%d %s %.3f %.3f %.3fn",s->num,s->name,s->cj[0],s->cj[1],s->cj[2]); s=s->next; }while(s!=NULL); }



