标签:main struct else lis mp3 int str bool for
大水题。。。
const int N=1e5+10;
struct Node
{
string id;
string name;
int grade;
}a[N];
int n,m;
bool cmp1(Node &a,Node &b)
{
return a.id < b.id;
}
bool cmp2(Node &a,Node &b)
{
if(a.name == b.name) return a.id < b.id;
return a.name < b.name;
}
bool cmp3(Node &a,Node &b)
{
if(a.grade == b.grade) return a.id < b.id;
return a.grade < b.grade;
}
int main()
{
ios;
cin>>n>>m;
for(int i=0;i<n;i++)
cin>>a[i].id>>a[i].name>>a[i].grade;
if(m == 1) sort(a,a+n,cmp1);
else if(m == 2) sort(a,a+n,cmp2);
else sort(a,a+n,cmp3);
for(int i=0;i<n;i++)
cout<<a[i].id<<‘ ‘<<a[i].name<<‘ ‘<<a[i].grade<<endl;
//system("pause");
return 0;
}
标签:main struct else lis mp3 int str bool for
原文地址:https://www.cnblogs.com/fxh0707/p/14403293.html