题目描述
blablabla
C++ 代码
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
struct w{
string id;
string name;
int score;
int c;
bool operator<(const w&a){
if(c==1) return id<a.id;
else if(c==2)
if(name!=a.name) return name<=a.name;
else return id<a.id;
else if(c==3)
if(score!=a.score) return score<a.score;
else return id<a.id;
}
};
int main(){
vector<w> res; //3行n列
int n,c;
scanf("%d%d",&n,&c);
char id[10],name[10];
int s;
for(int i=0;i<n;i++){
scanf("%s%s%d",id,name,&s);
res.push_back({id,name,s,c});
}
sort(res.begin(),res.end());
for(auto i:res){
printf("%s %s %d\n",i.id.c_str(),i.name.c_str(),i.score);
}
return 0;
}