提交时间:2024-05-25 15:17:39

运行 ID: 148942

#include<bits/stdc++.h> using namespace std; int main(){ int n,i,j; cin>>n; struct student{ double c,m,e,z,q; }a[301]; for(i=1;i<=n;i++){ cin>>a[i].c>>a[i].m>>a[i].e; a[i].q=i; a[i].z=a[i].c+a[i].m+a[i].e; } for(i=n-1;i>=1;i--){ for(j=1;j<=i;j++){ if(a[j].z>a[j+1].z){ swap(a[j].z,a[j+1].z); swap(a[j].q,a[j+1].q); } } } for(i=n;i>=n-4;i--){ cout<<a[i].q<<" "<<a[i].z<<endl; } return 0; }