文章
111
粉丝
69
获赞
180
访问
66.2k
#include<bits/stdc++.h>
using namespace std;
const int N = 1010;
int n;
struct student{
string name;
int age;
int score;
}s[N];
bool cmp(student a, student b)
{
if(a.score == b.score)
{
if(a.name == b.name) return a.age < b.age;
else return a.name < b.name;
}
return a.score < b.score;
}
int main()
{
while(cin >> n)
{
for(int i = 0; i < n; i ++)
cin >> s[i].name >> s[i].age >> s[i].score;
sort(s, s + n, cmp);
for(int i = 0; i < n; i ++)
cout << s[i].name << " " << s[i].age << " " << s[i].score << endl;
}
return 0;
}
登录后发布评论
暂无评论,来抢沙发