#include
#include
struct student
{int num;
char name[20];
float score[3];
};
void average_print(student *);
void top_print(student *);
void top1_print(student *);
void top2_print(student *);
void top3_print(student *);
int main()
{ student stu[3],*p;
int i;
cout<<"请输入3个学生数据:"<
{cin>>stu[i].num>>stu[i].name>>stu[i].score[0]>>stu[i].score[1]>>stu[i].score[2];
}
average_print(stu) ;
int z ;
do
{cout<<"请选择相应选项:"<
switch(z)
{ case 1:top_print(stu) ;break;
case 2:top1_print(stu) ;break;
case 3:top2_print(stu) ;break;
default:top3_print(stu) ;break;
}
}while(z!=0);
return 0;
}
void average_print(student p[])
{ float x=0,y=0,z=0;
int i;
for(i=0;i<3;++i)
{ x+=p[i].score[0];
y+=p[i].score[1];
z+=p[i].score[2];
}
cout<<"第一门课平均成绩"<
void top_print(student point[])
{int i,z;
float j;
student temp ;
temp=point[0];
j=point[0].score[0];
for(i=1;i<3;++i)
{ if(j<=point[i].score[0] )
{j=point[i].score[0];
temp= point[i];}
}
cout<<"这门课最高分为:"<
void top1_print(student point[])
{int i,z;
float j;
student temp ;
temp=point[0];
j=point[0].score[1];
for(i=1;i<3;++i)
{ if(j<=point[i].score[1] )
{j=point[i].score[1];
temp= point[i];}
}
cout<<"这门课最高分为:"<
void top2_print(student point[])
{int i,z;
float j;
student temp ;
temp=point[0];
j=point[0].score[2];
for(i=1;i<3;++i)
{ if(j<=point[i].score[2] )
{j=point[i].score[2];
temp= point[i];}
}
cout<<"这门课最高分为:"<
void top3_print(student point[])
{int i,z;
float j;
student temp ;
temp=point[0];
j=point[0].score[0]+point[0].score[1]+point[0].score[2];
for(i=1;i<3;++i)
{ if(j<=point[i].score[0]+point[i].score[1]+point[i].score[2])
{j=point[i].score[0]+point[i].score[1]+point[i].score[2];
temp= point[i];}
}
cout<<"这门课最高分为:"<