Run ID:3308
提交时间:2024-05-05 12:00:32
# include<iostream> # include<algorithm> using namespace std; struct Friend{ string name; long long bth, tp, age; void input(){ cin>>name>>bth>>tp; age = 2024 - bth / 100; } void output(){ cout<<name<<" "<<bth<<" "<<tp<<endl; } }; bool cmp(Friend f1, Friend f2){ if(f1.age!=f2.age)return f1.age>f2.age; if(f1.name!=f2.name)return f1.name<f2.name; return f1.tp<f2.tp; } Friend fs[10]; int n; int main(){ cin>>n; for(int i = 0; i < n; i++)fs[i].input(); sort(fs, fs+n, cmp); for(int i = 0; i < n; i++)fs[i].output(); return 0; }