#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
struct node
{
int id;
char name[20];
int grade;
}T[100005];
bool cmp1(node a,node b)
{
return a.id < b.id;
}
bool cmp2(node a,node b)
{
if(strcmp(a.name,b.name)!=0)
return strcmp(a.name,b.name)<0;
else
return a.id < b.id;
}
bool cmp3(node a,node b)
{
if(a.grade != b.grade)
return a.grade < b.grade;
else
return a.id < b.id;
}
int main()
{
//freopen("in.txt","r",stdin);
int N,C;
scanf("%d %d",&N,&C);
for(int i=0;i<N;i++)
scanf("%d %s %d",&T[i].id,T[i].name,&T[i].grade);
if(C==1)
sort(T,T+N,cmp1);
else if(C==2)
sort(T,T+N,cmp2);
else
sort(T,T+N,cmp3);
for(int i=0;i<N;i++)
printf("%06d %s %d\n",T[i].id,T[i].name,T[i].grade);
return 0;
}
1028. List Sorting (25)
最新推荐文章于 2023-07-17 19:25:43 发布