暑假作业第7题
作者:互联网
#include<stdio.h>
struct student
{
int num;
char name[20];
char sex;
int score[4];
int year;
int mouth;
int day;
float aver;
}stu[4]={{10031,“wanggang”,‘m’,72,83,90,82,1991,5,19},
{10032,“liming”,‘m’,88,92,78,78,1992,8,20},
{10033,“wangli”,‘f’,98,72,89,66,1991,9,19},
{10034,“chenhong”,‘f’,87,95,78,90,1991,9,19}};
void main()
{
int i,j,max=0,a=0,sum=0;
for(i=0;i<4;i++)
{
printf("%d\t%s\t%c\t%d\t%d\t%d\n",stu[i].num,stu[i].name,stu[i].sex,stu[i].year,stu[i].mouth,stu[i].day);
for(j=0;j<4;j++)
printf("%d\n",stu[i].score[j]);
}
for(i=0;i<4;i++)
{
for(j=0;j<4;j++)
sum+=stu[i].score[j];
stu[i].aver=sum/4.0;
printf("%.2f\n",stu[i].aver);
}
for(i=0;i<4;i++)
{
if(max<stu[i].aver)
{
max=stu[i].aver;
a=i;
}
}
printf("%d\t%s\t%c\t%.2f\n",stu[a].num,stu[a].name,stu[a].sex,stu[a].aver);
}
标签:int,sex,stu,printf,aver,t%,暑假作业 来源: https://blog.csdn.net/qq_54603387/article/details/118465319