输出平均分最高的学生信息
显示标签
时间限制:C/C++ 1000MS,其他语言 2000MS
内存限制:C/C++ 256MB,其他语言 512MB
难度:简单
描述
假设学生的基本信息包括学号、姓名、三门课程成绩以及个人平均成绩。输入n 个学生的成绩信息, 计算并输出平均分最高的学生信息。
输入描述
第一行:n 表示学生数
接下来n行,分别是每一个学生的信息
用例输入 1
3 101 Zhang 78 87 85 102 Wang 91 88 90 103 Li 75 90 84
用例输出 1
102 Wang 91 88 90
提示
代码
#include<bits/stdc++.h>
using namespace std;
struct xs{
int xh,cj1,cj2,cj3;
string name;
double pjf;
};
xs bj[55];
int main(){
int n,zb;
cin>>n;
double pj=0.00;
for(int i=0;i<n;i++){
cin>>bj[i].xh>>bj[i].name>>bj[i].cj1>>bj[i].cj2>>bj[i].cj3;
bj[i].pjf=(bj[i].cj1+bj[i].cj2+bj[i].cj3)/3.0;
}
for(int i=0;i<n;i++){
if(pj<bj[i].pjf){
pj=bj[i].pjf;
zb=i;
}
}
cout<<bj[zb].xh<<" "<<bj[zb].name<<" "<<bj[zb].cj1<<" "<<bj[zb].cj2<<" "<<bj[zb].cj3;
return 0;
}