AcWing 3601. 成绩排序
原题链接
简单
作者:
笔尖微凉_7
,
2024-03-03 22:12:03
,
所有人可见
,
阅读 16
#include <bits/stdc++.h>
using namespace std;
typedef struct student{
string name;
int age;
int score;
}stu;
const int N=10000;
stu a[N];
bool com(stu x , stu y){
if(x.score!=y.score) return x.score<y.score;
if(x.name!=y.name) return x.name<y.name;
if(x.age!=y.age) return x.age<y.age;
}
int main(){
int t;
cin >> t;
for(int i = 0 ; i < t ; i++){
cin >> a[i].name >> a[i].age >> a[i].score;
}
sort(a,a+t,com);
for(int j = 0 ; j < t ; j++){
cout << a[j].name << " " << a[j].age << " " << a[j].score<< endl;
}
return 0;
}