文章

119

粉丝

68

获赞

92

访问

20.1k

头像
成绩再次排序 题解:别忘了还有个序号
P1817 华南理工大学机试题
发布于2025年2月10日 14:49
阅读数 74

#include <bits/stdc++.h>

using namespace std;

struct Score{
    string name;
    int id;
    int chinese,math,english;
    Score():name(""),chinese(0),math(0),english(0),id(0){}
    Score(string name,int chinese,int math,int english,int id):name(name),chinese(chinese),math(math),english(english),id(id){}
    bool operator <(Score b){
        if(chinese+math+english==b.chinese+b.math+b.english){
            if(chinese==b.chinese){
                if(math==b.math){
                    if(english==b.english){
                        return id<b.id;
                    }else return english>b.english;
                }else return math>b.math;
            }else return chinese>b.chinese;
        }else return chinese+math+english>b.chinese+b.math+b.english;
    }
    void print(){
        cout<<name;
        printf(" %d %d %d\n",chinese,math,english);
    }
};

int main() {
    int n;
    while(cin>>n){
        std::vecto...
登录查看完整内容


登录后发布评论

暂无评论,来抢沙发