2446=最终排名

 1 #include <stdio.h>
 2 #include <stdlib.h>
 3 #include <string.h>
 4 struct node
 5 {
 6     int a;//结构体。
 7     int s;
 8 } st[10000],t;
 9 int main()
10 {
11     int n,i,j,T;
12     scanf("%d",&T);
13     while(T--)
14     {
15         scanf("%d",&n);
16         for(i=0;i<n;i++)
17         {
18             scanf("%d %d",&st[i].s,&st[i].a);
19         }
20         for(i=0; i<n; i++)
21         {
22             for(j=0; j<n-1-i; j++)
23             {
24                 if(st[j].a<st[j+1].a)t=st[j],st[j]=st[j+1],st[j+1]=t;
25             }
26         }
27         for(i=0;i<n;i++)
28         {
29             printf("%d %d\n",st[i].s,st[i].a);
30         }
31     }
32     return 0;
33 }

猜你喜欢

转载自www.cnblogs.com/Angfe/p/10436387.html