View Code of Problem 82

#include<stdio.h>
struct student{
	char num[10];
	char name[10];
	int c1;
	int c2;
	int c3;
};
int main()
{
	int n,i,max=0;
	double s1=0,s2=0,s3=0;
	scanf("%d",&n);
	struct student a[n];
	for(int i=0;i<n;i++)
	{
		scanf("%s %s %d %d %d",&a[i].num,&a[i].name,&a[i].c1,&a[i].c2,&a[i].c3);
		s1+=a[i].c1;
		s2+=a[i].c2;
		s3+=a[i].c3;
		if(a[max].c1+a[max].c2+a[max].c3<a[i].c1+a[i].c2+a[i].c3)
			max=i; 
	}
	printf("%.0lf %.0lf %.0lf\n",s1/n,s2/n,s3/n);
	printf("%s %s %d %d %d\n",a[max].num,a[max].name,a[max].c1,a[max].c2,a[max].c3);
	
}

Double click to view unformatted code.


Back to problem 82