View Code of Problem 82

#include <stdio.h>
struct student
{
	char number[50];
	char name[50];
	double s[3];
}st,temp;
int main()
{
	int i,j,n;
	double sum,ave,max=0,a[3]={0};
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		sum=ave=0;
		scanf("%s %s",st.number,st.name);
		for(j=0;j<3;j++)
		{
			scanf("%lf",&st.s[j]);
			sum+=st.s[j];
			a[j]+=st.s[j];
		}
		ave=sum/3.0;
		if(max<ave)
		{			
			max=ave;
			temp=st;
		}
	}
	printf("%.lf %.lf %.lf\n",a[0]/n,a[1]/n,a[2]/n);
	printf("%s %s %.lf %.lf %.lf\n",temp.number,temp.name,temp.s[0],temp.s[1],temp.s[2]);
	return 0;
}

Double click to view unformatted code.


Back to problem 82