#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<cstring>
#include<cmath>
#include<map>
#include<stack>
#define N 10005
#define ll long long
using namespace std;
struct node
{
char id[110],name[10];
int sc;
}p[100005];
const bool cmp1(const node &x,const node &y)
{
return strcmp(x.id,y.id)<0;
}
const bool cmp2(const node &x,const node &y)
{
if(!strcmp(x.name,y.name))return strcmp(x.id,y.id)<0;
return strcmp(x.name,y.name)<0;
}
const bool cmp3(const node &x,const node &y)
{
if(x.sc == y.sc)return strcmp(x.id,y.id)<0;
return x.sc<y.sc;
}
int main()
{
int n,c,i,j;
while(scanf("%d%d",&n,&c)!=EOF)
{
for(i = 0;i<n;i++)scanf("%s%s%d",p[i].id,p[i].name,&p[i].sc);
if(c == 1)sort(p,p+n,cmp1);
if(c == 2)sort(p,p+n,cmp2);
if(c == 3)sort(p,p+n,cmp3);
for(i = 0;i<n;i++)printf("%s %s %d\n",p[i].id,p[i].name,p[i].sc);
}
return 0;
}
pat1028 List Sorting
最新推荐文章于 2020-07-05 14:52:32 发布