提交时间:2024-05-18 17:03:54

运行 ID: 147638

#include<iostream> #include<iomanip> #include<cstdio> using namespace std; struct student{ int num; char name[9]; double chinese; double math; double english; double total; double pj; }a[11]; int main(){ double sum=0; for(int i=1;i<=10;i++){ cin>>a[i].num>>a[i].name>>a[i].chinese>>a[i].math>>a[i].english; a[i].total=a[i].chinese+a[i].math+a[i].english; a[i].pj=(a[i].chinese+a[i].math+a[i].english)/3; } for(int i=1;i<=10;i++){ sum+=a[i].total; } cout<<fixed<<setprecision(2)<<sum/30<<endl; for(int i=1;i<=9;i++){ for(int j=i+1;j<=10;j++){ if(a[i].pj<a[j].pj){ swap(a[i].pj,a[j].pj); swap(a[i].num,a[j].num); swap(a[i].name,a[j].name); } } } cout<<a[1].num<<" "<<a[1].name<<" "<<a[1].pj; return 0; }