#include <stdio.h>
#include <malloc.h>
struct student
{
char id[20];
char name[10];
float english;
float math;
float c;
struct student *next;
};
struct student* create(void)
{
struct student*p=(struct student*)malloc(sizeof(struct student));
scanf("%s %s %f %f %f",p->id,p->name,&p->english,&p->math,&p->c);
p->next=NULL;
return p;
}
void input(struct student*head)
{
int i;
struct student*p=head;
for (i=0;i<9;i++)
{
while (p->next!=NULL)
{
p=p->next;
}
p->next=create();
}
}
void average(struct student*head)
{
int i;
float mo;
struct student*p=head;
for (mo=0,i=0;p!=NULL;p=p->next,i++)
{
printf("%f %f\n",p->english+p->math+p->c,(p->english+p->math+p->c)/3);
mo+=(p->english+p->math+p->c);
}
printf("%f\n",mo/i);
}
void maximum(struct student*head)
{
struct student*p=head;
float most=p->english+p->math+p->c;
int i=0,mostint=0;
while (p!=NULL)
{
if(most<(p->english+p->math+p->c))
{
most=p->english+p->math+p->c;
mostint=i;
}
i++;
p=p->next;
}
for (p=head,i=0;i<mostint;i++,p=p->next)
{
;
}
printf("%s %s %f %f %f\n",p->id,p->name,p->english,p->math,p->c);
}
int main()
{
struct student stu,*head;
printf("Input information!\n");
scanf("%s %s %f %f %f",stu.id,stu.name,&stu.english,&stu.math,&stu.c);
head=&stu;
head->next=NULL;
input(head);
average(head);
maximum(head);
return 0;
}