Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
67394 | 冯诚阳 | 奖学金 | C++ | Accepted | 1 MS | 276 KB | 846 | 2024-03-16 14:51:03 |
#include<iostream> #include<cstring> #include<cmath> #include<iomanip> using namespace std; struct Stu{ int no; int ch; int math; int en; int toto; }; bool cmp(Stu x,Stu y){ if(x.toto<y.toto) return true; else if(x.toto==y.toto){ if(x.ch<y.ch) return true; else if(x.ch==y.ch){ 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].ch>>a[i].math>>a[i].en; a[i].toto=a[i].ch+a[i].math+a[i].en; } for(int i=0;i<n-1;i++){ for(int j=0;j<n-i-1;j++){ if(cmp(a[j],a[j+1])) swap(a[j],a[j+1]); } } for(int i=0;i<5;i++){ cout<<a[i].no<<" "<<a[i].toto<<endl; } return 0; }