提交时间:2024-05-25 15:04:39
运行 ID: 148859
#include<iostream> using namespace std; struct student{ int num; int c; int m; int e; int total; }; int main(){ int n; cin>>n; struct student a[n+1]; for(int i=1;i<=n;i++){ a[i].num=i; cin>>a[i].c>>a[i].m>>a[i].e; a[i].total=a[i].c+a[i].m+a[i].e; } for(int i=1;i<=n-1;i++){ for(int j=i+1;j<=n;j++){ if(a[i].total<a[j].total){ swap(a[i].num,a[j].num); swap(a[i].total,a[j].total); } } } for(int i=1;i<=5;i++) cout<<a[i].num<<" "<<a[i].total<<endl; return 0; }