文章
64
粉丝
100
获赞
4
访问
36.1k
#include <bits/stdc++.h>
using namespace std;
struct Student{
string name;
int age;
int grade;
}stu[1000];
bool grade_ASC(Student a,Student b)
{
return a.grade<b.grade;
}
bool name_ASC(Student a,Student b)
{
return a.name<b.name;
}
bool age_ASC(Student a,Student b)
{
return a.age<b.age;
}
int main()
{
int n;
while(cin>>n)
{
for(int i=0;i<n;i++)
{
cin>>stu[i].name>>stu[i].age>>stu[i].grade;
}
stable_sort(stu,stu+n,age_ASC);
stable_sort(stu,stu+n,name_ASC);
stable_sort(stu,stu+n,grade_ASC);
for(int i=0;i<n;i++)
{
cout<<stu[i].name<<" "<<stu[i].age<<" "<<stu[i].grade<<endl;
}
}
}
登录后发布评论
暂无评论,来抢沙发