zoukankan      html  css  js  c++  java
  • 【Gym 100712A】Who Is The Winner?

    题意

    解题数目越多越排前,解题数目相同罚时越少越排前,求排第一的队伍名字。

    分析

    用结构体排序。

    代码

    #include<cstdio>
    #include<algorithm>
    using namespace std;
    
    struct team
    {
        char name[25];
        int s,p;
    } a[105];
    int t,n;
    
    int cmp(team a,team b)
    {
        return a.s>b.s||a.s==b.s&&a.p<b.p;
    }
    
    int main()
    {
        scanf("%d",&t);
        while(t--)
        {
            scanf("%d",&n);
            for(int i=1; i<=n; i++)
                scanf("%s%d%d",a[i].name,&a[i].s,&a[i].p);
            sort(a+1,a+1+n,cmp);
            printf("%s
    ",a[1].name);
        }
        return 0;
    }
  • 相关阅读:
    【leetcode】1230.Toss Strange Coins
    2018.12.25 SOW
    L203 词汇题
    L202
    L201
    L200
    2018
    2018.12.21 Cmos- RF
    L198
    L196 Hospital educations
  • 原文地址:https://www.cnblogs.com/flipped/p/5188427.html
Copyright © 2011-2022 走看看