全文预览

C强化训练实验报告

上传者:upcfxx |  格式:doc  |  页数:24 |  大小:273KB

文档介绍
)Рstruct studentР{Р?long num;Р?float score;Р?struct student *next;Р};Р?int n,z;Рstruct student *creat(void)Р{Р?struct student *head;Р?struct student *p1,*p2;Р?n=0;Р?p1=p2=(struct student*)malloc(LEN);Р?printf("输入学生的个数:");Р?scanf("%d",&z);Р?printf("输入完毕后以00作为结束\n");Р?printf("\n请输入%d个学生的学号和成绩:\n",z);Р?printf("\n学号");Р?scanf("%f",&p1->score);Р?printf("成绩");Р scanf("%ld",&p1->num);Р 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%f",&p1->num,&p1->score);Р?}Р?p2->next=NULL;Р?return(head);Р}Рvoid print(struct student *head)Р{Р?float max,min,average;Р?int i=0;Р?struct student *p;Рif(head!=NULL)Р?{Р p=head;Р max=p->score;Р min=p->score;Р average=0;РdoР {Р if(max<p->score)Р {Р max=p->score;Р }Р if(min>p->score)Р {

收藏

分享

举报
下载此文档