#include <iostream>
#include <algorithm>
#include<stdio.h>
#include<math.h>
using namespace std;
struct student
{
int n,t;
char name[10];
}w[2000];
bool cmp(student x,student y)
{
if(x.n==y.n)return x.t<y.t;
else return x.n>y.n;
}
int main()
{
int M,N,C,i;
scanf("%d",&C);
while(C--)
{
scanf("%d %d",&N,&M);
for(i=0;i<N;i++)
{
scanf("%s %d %d",&w[i].name,&w[i].n,&w[i].t);
}
sort(w,w+N,cmp);
for(i=0;i<M;i++)
{
printf("%s %d %d\n",w[i].name,w[i].n,w[i].t);
}
}
return 0;
}
总结:
1.sort排序结构体数组的应用
2.字符串以\0结尾