#include <stdio.h>
#include <algorithm>
#include <cstring>using namespace std;
struct Student
{
char name[10];
int number;
int sorce;
}st[100000];bool cmp1(Student a, Student b)
{
return a.number < b.number;
}
bool cmp2(Student a, Student b)
{
int tmp = strcmp(a.name, b.name);
if(tmp != 0)
return tmp < 0;
else
return a.number < b.number;
}
bool cmp3(Student a, Student b)
{
if(a.sorce != b.sorce)
return a.sorce < b.sorce;
else
return a.number < b.number;
}int main()
{
int n, m;
int cnt = 1;
while(~scanf("%d%d", &n, &m) && n != 0)
{
for(int i = 0; i < n; i++)
scanf("%d %s %d", &st[i].number, st[i].name, &st[i].sorce);
if(m == 1)
sort(st, st+n, cmp1);
else if(m == 2)
sort(st, st+n, cmp2);
else
sort(st, st+n, cmp3);
printf("Case %d:\n", cnt);
for(int i = 0; i < n; i++)
printf("%06d %s %d\n", st[i].number, st[i].name, st[i].sorce);
cnt++;
}
return 0;
}
02-10
703
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
07-27