Problem F: 尖兵

#include<stdio.h>
struct man{
    char name[10];
    int grade;
};
int main(void)
{
    int t;
    int i,j,n;
    struct man s1[50],max;
    scanf("%d",&t);
    while(t!=0)
    {
        scanf("%d",&n);
        for(i=0;i<n;i++)
        scanf("%s %d",s1[i].name,&s1[i].grade);
    for(i=0;i<n-1;i++)
            for(j=i+1;j<n;j++)
                if(s1[i].grade<s1[j].grade)
                {
                    max=s1[i];
                    s1[i]=s1[j];
                    s1[j]=max;
                }
        for(i=0;i<n;i++)
        printf("%s\n",s1[i].name);
        t--;
    }
    return 0;
}

 

posted @ 2018-12-08 16:45  MichaelCecil  阅读(1327)  评论(0编辑  收藏  举报