#include
#define n 5
int num;
struct student
{int num;
char name[23];
float score[3];
float aver;};
int main()
{ void print2(struct student stu);
void print1(struct student stu);
struct student max(struct student stu[]);
struct student min(struct student stu[]);
struct student stu[n],*p=stu;
int i;
printf("请输入数据:以学号为0结束输入:\n");
for(i=0;i
scanf("%d%s%f%f%f",&stu[i].num,stu[i].name,&stu[i].score[0],&stu[i].score[1],&stu[i].score[2]);
stu[i].aver=(stu[i].score[0]+stu[i].score[1]+stu[i].score[2])/3.0;
if (stu[i].num==0)
{
num=i;
break;
}
}
for(i=0;i
printf("%d\t%s\t%f\t%f\t%f\t%f\n",stu[i].num,stu[i].name,stu[i].score[0],stu[i].score[1],stu[i].score[2],stu[i].aver);
}
print1(max(p));
print2(min(p));
}
struct student max(struct student stu[])
{int i,m=0;
for(i=0;i
return stu[m];
}
struct student min(struct student stu[])
{int i,m=0;
for(i=0;i
}
void print1(struct student stud)
{ printf("\n成绩最高的学生是:\n");
printf("学号:%d\n姓名:%s\n三门课成绩:%5.1f,%5.1f,%5.1f\n平均成绩:%6.2f\n", stud.num,stud.name,stud.score[0],stud.score[1],stud.score[2],stud.aver);
}
void print2(struct student stud)
{ printf("\n成绩最低的学生是:\n");
printf("学号:%d\n姓名:%s\n三门课成绩:%5.1f,%5.1f,%5.1f\n平均成绩:%6.2f\n",stud.num,stud.name,stud.score[0],stud.score[1],stud.score[2],stud.aver);
}