Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
65725 黄子航 奖学金 C++ Accepted 1 MS 276 KB 756 2024-02-03 17:14:21

Tests(10/10):


Code:

#include<iostream> #include<cstdio> #include<cstring> 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;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].total<<endl; return 0; }