#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
struct student{
string ID;
string name;
int grade;
}stu[100001];
bool cmp1(student a,student b){
return a.ID<b.ID;
}
bool cmp2(student a,student b){
if(a.name!=b.name)
return a.name<b.name;
else
return a.ID<b.ID;
}
bool cmp3(student a,student b){
if(a.grade!=b.grade)
return a.grade<b.grade;
else
return a.ID<b.ID;
}
int main(){
int N,C;
cin>>N>>C;
for(int i=0;i<N;i++)
cin>>stu[i].ID>>stu[i].name>>stu[i].grade;
if(C==1)
sort(stu,stu+N,cmp1);
else if(C==2)
sort(stu,stu+N,cmp2);
else
sort(stu,stu+N,cmp3);
for(int i=0;i<N;i++)
{
cout<<stu[i].ID<<" "<<stu[i].name<<" "<<stu[i].grade;
if(i!=N-1)
cout<<endl;
}
return 0;
}
1028 List Sorting
最新推荐文章于 2024-06-26 21:53:02 发布