时间限制: 1 秒, 内存限制: 32 兆

题目描述

Is this your first times participating in this kind of contest? I think most of you will answer “Yes”. So let’s do this problem as warm-up and check whether the PC^2 work properly.
Now, we will give you the information of some contests that are just like the one you are taking. Your task is to output their rank lists according to the contest rules you have already understood.
 

输入格式

There is only one number C (<=100) in the first line of the input, which is the number of contests.
For each contest, the first line contains only one number N indicating the total number of teams. And then follow N lines. Each line has three numbers Ti, Si and Pi (1<=Ti<=N, 0<=Si<=20, 0<=Pi<=10000), which stand for the ID, Score and Penalty of the ith team of the contest respectively. Specially, all teams’ scores are distinct.
 

输出格式

For each contest, you should output the rank list (team ID) in descent order in just one line. Numbers separate exactly one space.

样例输入

2
3
3 2 200
2 1 100
1 3 300
2
1 2 222
2 1 222

样例输出

1 3 2
1 2
题目很简单的,觉得甚至给出了没有用的数据,题目中说score 不同,那就比较它的大小就可以了

#include<stdio.h>
struct student{
       int a;
       int s;
       int p;
       }stu[100],ptr;
int main()
{
    int t,i,j;
    scanf("%d",&t);
while(t--){
        int n;
        scanf("%d",&n);
       
for(i=0;i<n;i++){
        scanf("%d%d%d",&stu[i].a,&stu[i].s,&stu[i].p);
        }
for(i=0;i<n;i++){
    int k=i;
for(j=i+1;j<n;j++){
                   if(stu[j].s>stu[k].s) k=j;
                   }
    ptr=stu[k];
    stu[k]=stu[i];
    stu[i]=ptr;
}
for(i=0;i<n;i++){
  if(i==0)  printf("%d",stu[i].a);
else   printf(" %d",stu[i].a);
}
printf("\n");
}
return 0;
}