View Code of Problem 82

#include<stdio.h>
#include<math.h>
struct student{
char a[10];
char n[10];
int x,y,z;
};
int main()
{
struct  student stu[100];
int m,i,ave1=0,ave2=0,ave3=0,max1,max2,max3,j=0;
scanf("%d",&m);
for(i=0;i<m;i++)
{
scanf("%s %s %d%d%d",&stu[i].a,&stu[i].n,&stu[i].x,&stu[i].y,&stu[i].z);
ave1+=stu[i].x;
ave2+=stu[i].y;
ave3+=stu[i].z;
}
ave1=ave1/m;
ave2=ave2/m;
ave3=ave3/m;
printf("%d %d %d\n",ave1,ave2,ave3);
max1=stu[0].x;max2=stu[0].y;max3=stu[0].z;
for(i=1;i<m;i++)
if(stu[i].x>max1&&stu[i].y>max2&&stu[i].z>max3)
{max1=stu[i].x;
max2=stu[i].y;
max3=stu[i].z;
j=i;

}
printf("%s %s %d %d %d",stu[j].a,stu[j].n,stu[j].x,stu[j].y,stu[j].z);
}

Double click to view unformatted code.


Back to problem 82