这题简单
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
struct Student
{int id;char name[10];int grade;
}student[100010];bool cmp1(Student a,Student b)
{return a.id<b.id;
}bool cmp2(Student a,Student b)
{if(strcmp(a.name,b.name)!=0) return strcmp(a.name,b.name)<0;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;scanf("%d %d",&N,&C);for(int i = 0;i<N;i++){scanf("%d %s %d",&student[i].id,student[i].name,&student[i].grade);}if(C==1){sort(student,student+N,cmp1);for(int i =0;i<N;i++){printf("%06d %s %d\n",student[i].id,student[i].name,student[i].grade);}}if(C==2){sort(student,student+N,cmp2);for(int i =0;i<N;i++){printf("%06d %s %d\n",student[i].id,student[i].name,student[i].grade);}}if(C==3){sort(student,student+N,cmp3);for(int i =0;i<N;i++){printf("%06d %s %d\n",student[i].id,student[i].name,student[i].grade);}}return 0;
}