Start: Mar, 06, 2018 09:46:00
计算机161 算法分析与设计 第一次实验课作业(吴银杰、张凯庆)
End: Mar, 10, 2018 10:00:00
Time elapsed:
Time remaining:

Problem_ID: F
Result: Accepted
Time: 11ms
Memory: 1096kB
Author: xiaoluosi
In contest: 1141

#include <stdio.h>
#include<string.h>
#include<stdlib.h>
struct stu{
	char name[35];
	int a,b,c;
}s[100];
int comp(const void *p,const void *q)
{
	struct stu *x = (struct stu *)p;
	struct stu *y = (struct stu *)q;
	return (*y).c - (*x).c;
}
int main() {
    int t,n;
    int pass,i,temp;
    //stu s[100];
    scanf("%d",&t);
    while(t--){
    	scanf("%d",&n);
    	for(int g=0;g<n;g++){
    		scanf("%s %d %d",&s[g].name,&s[g].a,&s[g].b);
    		s[g].c = s[g].a + s[g].b;
		}
    		/*for(pass=0;pass<n;++pass){
                for(i=0;i<n-pass;++i){
                    if(s[i].c<s[i+1].c){
                        temp=s[i].c;
                        s[i].c=s[i+1].c;
                        s[i+1].c=temp;
						char cc[35];
						strcpy(cc,s[i].name);
						strcpy(s[i].name,s[i + 1].name);
						strcpy(s[i + 1].name,cc);
                    }
                }
            }*/
		qsort(s,n,sizeof(struct stu),comp);
            for(int p=0;p<n;p++){
            	printf("%s\n",s[p].name);
			}	
	}
}