# 结构体数组内数组的所有数据大小比较，c语言学生成绩，所有成绩中的最高分并输出，总成绩最高的学生，输出该学生的基本信息及总成绩。

char stuName[10],

float scoreEMP[3],

};

"Input stuName:n"

"Input scoreEMP:n"

"The high score is %.2f.n"

"The student's stuID %s,stuName %s,scoreEMP:%.2f,%.2f,%.2f,total score %.2f.n"

``````#include<stdio.h>
#define N 4
struct stu
{
char stuID[13];
char stuName[10];
float scoreEMP[3];
};
void inputdata(struct stu s[N]);
void findMAXscore(struct stu s[N]);
void totalScore(struct stu s[N]);
int main()
{
struct stu s[N];
inputdata(s);
findMAXscore(s);
totalScore(s);
return 0;
}
void inputdata(struct stu s[N])
{
int i;
for(i=0;i<=4;i++)
{
printf("input stuID:n");
gets(s[i].stuID);
printf("input stuName:n");
gets(s[i].stuName);
printf("input scoreEMP:n");
scanf("%f%f%f",&s[i].scoreEMP[0],&s[i].scoreEMP[1],&s[i].scoreEMP[2]);
while(getchar()!='n');
}
}
void findMAXscore(struct stu s[])
{
float maxscore;
int x,y,i;
float z[14],max;
y=0;
for(i=0;i<15;i=i+3)
{
z[i]=s[y].scoreEMP[0];
z[i+1]=s[y].scoreEMP[1];
z[i+2]=s[y].scoreEMP[2];
y++;
}
max=z[0];
for(x=0;x<15;x++)
{
if(max<=z[x])
{
max=z[x];
}
}
maxscore=max;
printf("The high score is %.2f.n",maxscore);
}
void totalScore(struct stu s[])
{
int i,j;
int m;
float sum[N],k,total;
for(i=0;i<5;i++)
{
sum[i]=s[i].scoreEMP[0]+s[i].scoreEMP[1]+s[i].scoreEMP[2];
}
k=sum[0];
m=0;
for(j=1;j<5;j++)
{
if(k<sum[j])
{
k=sum[j];
m=j;
}
}
total=s[m].scoreEMP[0]+s[m].scoreEMP[1]+s[m].scoreEMP[2];
printf("The student stuID %s,stuName:%s,scoreEMP:%.2f,%.2f,%.2f,totalscore%.2f.n",
s[m].stuID,
s[m].stuName,
s[m].scoreEMP[0],s[m].scoreEMP[1],s[m].scoreEMP[2],total);
}``````

THE END