Result: Accepted
Time: 14ms
Memory: 1092kB
#include <stdio.h>
#include <stdlib.h>
#define ARRAY_SIZE 100
struct student{
char name[20];
int f1;
int f2;
int z;
};
int comp(const void *p,const void *q){
return((struct student *)q)->z-((struct student *)p)->z;
}
int main()
{
struct student studentArray[ARRAY_SIZE];
int T,n,i,j,k;
scanf("%d",&T);
while(T--){
scanf("%d",&n);
for(i=0;i<n;++i){
scanf("%s %d %d",studentArray[i].name,&studentArray[i].f1,&studentArray[i].f2);
studentArray[i].z=studentArray[i].f1+studentArray[i].f2;
}
qsort(studentArray,n,sizeof(struct student),comp);
for(i=0;i<n;i++)
printf("%s\n",studentArray[i].name);
}
return 0;
}