文章

3

粉丝

217

获赞

2

访问

7.0k

头像
1310_奥运排序问题
我要提问
发布于2023年3月18日 21:31
阅读数 2.1k

代码逻辑如下,不能通过全部测试数据,问下各位大佬哪里有问题呢?

 

#include <bits/stdc++.h>

using namespace std;

struct country{
    float gold_medal;
    float medals;
    double gold_proportion;
    double medal_proportion;
    int num;
}t[1005],t1[1005];


int cmp1(country a, country b){
    if(a.gold_medal==b.gold_medal) return a.num>b.num;
    return a.gold_medal>b.gold_medal;
}

int cmp2(country a, country b){
    if(a.medals==b.medals) return a.num>b.num;
    return a.medals>b.medals;
}

int cmp3(country a, country b){
    if(a.gold_proportion==b.gold_proportion) return a.num>b.num;
    return a.gold_proportion>b.gold_proportion;
}

int cmp4(country a, country b){
    if(a.medal_proportion==b.medal_proportion) return a.num>b.num;
    return a.medal_proportion>b.medal_proportion;
}

int get_rank(country a,i...

登录查看完整内容


登录后发布评论

1 条评论
admin SVIP
2023年3月19日 13:41

代码有点问题,比如这组数据

10 10
3 6 7
5 3 5
6 2 9
1 2 7
0 9 3
6 0 6
2 6 1
8 7 9
2 0 2
3 7 5
0 1 2 3 4 5 6 7 8 9

赞(0)