#include <stdio.h>
#include <stdlib.h>
struct team
{
char name[32];
int jf,jsq;
};
int cmp (const void* a,const void* b)
{
struct team *a1=(struct team*)a,*b1=(struct team*)b;
if(b1->jf==a1->jf)return b1->jsq-a1->jsq;
return b1->jf-a1->jf;
}
int main()
{
int i,j,n;
scanf("%d",&n);
struct team teams[n],tmp={0};;
for(i=0;i<n;i+=1)scanf("%s%d%d",teams[i].name,&teams[i].jf,&teams[i].jsq);
qsort(teams,n,sizeof(struct team),cmp);
for(i=0,j=0;i<n;i+=1)
{
if(tmp.jf!=teams[i].jf||teams[i].jsq!=tmp.jsq)j+=1;
printf("%d %s %d %d\n",j,teams[i].name,teams[i].jf,teams[i].jsq);
tmp=teams[i];
}
6
shanggang1 50 18
hengda 45 20
shanggang 50 18
luneng 40 15
hengda1 45 20
luneng1 40 16
1 shanggang 50 18
1 shanggang1 50 18
2 hengda1 45 20
2 hengda 45 20
3 luneng1 40 16
4 luneng 40 15
Process returned 0 (0x0) execution time : 1.402 s
Press any key to continue.
return 0;
}
|