1018

作者: 峡迩 | 来源:发表于2017-07-22 22:29 被阅读0次
#include<iostream>
#include<array>
#include<cctype>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;

class games
{
public:
    games() = default;
    games(istream &in) { in >> a >> b; }
    int get_result_a();
    string get_a()const { return a; }
    string get_b()const { return b; }

private:
    string a;
    string b;
};

int games::get_result_a()   //返回值0代表平局,1代表胜利,-1代表失败
{
    if (a == "C")
    {
        if (b == "C")
            return 0;
        if (b == "J")
            return 1;
        if (b == "B")
            return -1;
    }
    if (a == "J")
    {
        if (b == "J")
            return 0;
        if (b == "B")
            return 1;
        if (b == "C")
            return -1;
    }
    if (a == "B")
    {
        if (b == "B")
            return 0;
        if (b == "C")
            return 1;
        if (b == "J")
            return -1;
    }
}

const string max_vin(vector<string> &a)
{
    unsigned v_c = count(a.cbegin(), a.cend(), "C");
    unsigned v_j = count(a.cbegin(), a.cend(), "J");
    unsigned v_b = count(a.cbegin(), a.cend(), "B");

    if (v_b >= v_c && v_b >= v_j)
        return "B";
    if (v_j > v_b && v_j > v_c)
        return "J";
    if (v_c >= v_j && v_c > v_b)
        return "C";
}


int main()
{
    unsigned n;
    cin >> n;

    vector<games> play_game;
    while (n>0)
    {
        games tmp(cin);
        play_game.push_back(tmp);
        --n;
    }

    vector<string> a_result, b_result;
    unsigned pj = 0;
    for (auto &r : play_game)
    {
        if (1 == r.get_result_a())
            a_result.push_back(r.get_a());
        if (-1 == r.get_result_a())
            b_result.push_back(r.get_b());
        if (0 == r.get_result_a())

            ++pj;
    }

    cout << a_result.size() << " " << pj << " " << b_result.size() << endl;
    cout << b_result.size() << " " << pj << " " << a_result.size() << endl;

    cout << max_vin(a_result) << " " << max_vin(b_result);

    cout << endl;
    system("pause");
    return 0;
}

相关文章

  • 2019-10-18

    1018

  • [PAT]A1018(Public Bike Managemen

    原题回顾 PAT_A1018原文链接 1018 Public Bike Management (30分) 作者: ...

  • 笔记

    犯罪心理 1018

  • 随笔

    有个爱你的人不容易-----1018

  • 1018

    今天早晨,是鼻涕虫感冒的节奏,赶脚自己好难受,还要赶飞机,司机师傅大概还在实习期……哈哈哈让我做出过山车的感觉,某...

  • 1018

    //1018 锤子剪刀布(20 分)//大家应该都会玩“锤子剪刀布”的游戏:两人同时给出手势,胜负规则如下://现...

  • 1018

  • 1018

  • 1018

    努力生活,不论怎样 怕的是你有一颗想扎在泥潭里的心 怕的是你以为会慢慢变好 一下子全部变回了原来的样子 我好像一直...

  • 1018

    早上好!#幸福实修#~每天进步1%#幸福实修12班@吕敏一富阳 20171018(22/30) 【幸福三朵玫瑰】 ...

网友评论

      本文标题:1018

      本文链接:https://www.haomeiwen.com/subject/avcpkxtx.html