文章

1

粉丝

169

获赞

1

访问

7.7k

头像
通俗易懂解法
P1310 浙江大学机试题
发布于2021年4月3日 10:21
阅读数 7.7k

#include <bits/stdc++.h>
using namespace std;

class country{
    public:
        int id;
        int M_g, M;
        int pop;
        float averM_g, averM;
        int best, method;
};

bool cmp1(country a, country b){
    return a.M_g > b.M_g;
}

bool cmp2(country a, country b){
    return a.M > b.M;
}

bool cmp3(country a, country b){
    return a.averM_g > b.averM_g;
}

bool cmp4(country a, country b){
    return a.averM > b.averM;
}

int main(){
    int N, M;
    while(cin>>N>>M){
        int flag[N];
        for(int i=0;i<N;i++)
            flag[i] = 0;
        country a[N];
        country a1[N];
        for(int i=0;i<N;i++)
            cin>>a[i].M_g>>a[i].M>>a[i].pop;
        for(int i=0;i<N;i++){
            a[i].id = i;
            a[i].averM_g = float(a[i].M_g / a[i].pop) ;
            a[i].averM = float(a[i].M / a[i].pop) ;
        }

        //将需排名的国家存入a1中
        int...
登录查看完整内容


登录后发布评论

暂无评论,来抢沙发