Run ID:131562
提交时间:2025-09-27 17:26:15
#include <iostream> #include <algorithm> using namespace std; struct Stu{ int no; int chinese; int math; int english; int total; }; bool cmp(Stu x,Stu y) { if(x.total<y.total) return true; else if(x.total==y.total) { if(x.chinese<y.chinese) return true; else if(x.chinese==y.chinese) return x.no>y.no; } return false; int main(){ int n; Stu a[301]; cin>>n; for(int i=0;i<n;i++){ a[i].no=i+1 cin>>a[i].chinese+a[i].math>>a[i].english; a[i].total=a[i].chinese+a[i].math+a[i]english; } for(int i=0;i<n-1;i++) for(int j=0;j<n-i-1;i++) if(cmp(a[j],a[j+1])) swap(a[i],a[j+1]); for(int i=0;i<=5){ cout<<a[i].no<<" "<<a[i].total<<endl; } return 0; }