Result: Accepted
Time: 13ms
Memory: 1092kB
#include <stdio.h>
struct student{
char name[21];
int mark1,mark2,sum;
};
void bubblesort(struct student sore[],int n);
int main(){
int t,n,i;
struct student sore[100];
scanf("%d",&t);
while(t--){
scanf("%d",&n);
for(i=0;i<n;++i){
scanf("%s%d%d",sore[i].name,&sore[i].mark1,&sore[i].mark2);
sore[i].sum=sore[i].mark1+sore[i].mark2;
}
bubblesort(sore,n);
for(i=0;i<n;++i)
printf("%s\n",sore[i].name);
}
return 0;
}
void bubblesort(struct student sore[],int n){
int i,j;
struct student temp;
for(i=1;i<n;++i){
for(j=0;j<n-i;++j){
if(sore[j].sum < sore[j+1].sum){
temp=sore[j];
sore[j]=sore[j+1];
sore[j+1]=temp;
}
}
}
}