AcWing 3601. 成绩排序
原题链接
简单
作者:
fib纳7
,
2024-02-27 13:02:19
,
所有人可见
,
阅读 34
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1111;
struct st
{
string name;
int age,score;
}stu[maxn];
bool cmp(st x,st y)
{
if(x.score != y.score) return x.score<y.score;
if(x.name != y.name) return x.name<y.name;
return x.age<y.age;
}
int main()
{
int n; cin>>n;
for(int i=0;i<n;i++)
{
cin>>stu[i].name>>stu[i].age>>stu[i].score;
}
sort(stu,stu+n,cmp);
for(int i=0;i<n;i++)
{
cout<<stu[i].name<<" "<<stu[i].age<<" "<<stu[i].score<<endl;
}
return 0;
}