祝各位RP++站外题求助(悬关)
  • 板块题目总版
  • 楼主封禁用户
  • 当前回复9
  • 已保存回复9
  • 发布时间2023/10/22 10:52
  • 上次更新2023/11/2 11:58:37
查看原帖
祝各位RP++站外题求助(悬关)
1011214
封禁用户楼主2023/10/22 10:52

违规紫衫

澳门游乐场

描述

Eric最近在澳门旅游,澳门游乐场有这样一个骰子游戏,他们使用三颗六面骰子,游戏规则如下:点数的优先级是6、5、4、3、2、1,当三个骰子的点数都相同时,称为“豹子”,豹子按点数优先级比较大小;当两个骰子的点数相同时,称为“对子”,所有对子都按剩余骰子的点数优先级比较;其他情况称为“点子”,点子按点数和比较大小;豹子比对子、点子大,对子比点子大,现在Eric需要和电脑先模拟投骰子的情况,请你来判断一下胜负情况。

输入描述

第一行为一个正整数n,表示一共有n次游戏,以后每两行表示一个样例,第一行是Eric骰子的点数,第二行为电脑骰子的点数。

输出描述

输出有n行,如果是Eric赢,则输出"Eric",如果是电脑赢,则输出"Computer",其他情况都输出"Balance"。

用例输入 1

3
1 1 1 
1 1 1 
2 1 2
4 5 4
4 5 6
4 5 3

用例输出 1

Balance
Computer
Eric

提示

1<=n<=1000

附上楼主写的答辩代码:

#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

string judge(int a, int b, int c) {
    if (a == b && b == c) {
        return "豹子";
    } else if (a == b || b == c || a == c) {
        return "对子";
    } else {
        return "点子";
    }
}

int main() {
    int n;
    cin >> n;
    
    for (int i = 0; i < n; i++) {
        int a[3], b[3];
        for (int j = 0; j < 3; j++) {
            cin >> a[j];
        }
        for (int j = 0; j < 3; j++) {
            cin >> b[j];
        }
        sort(a, a + 3);
        sort(b, b + 3);
        
        string typeA = judge(a[0], a[1], a[2]);
        string typeB = judge(b[0], b[1], b[2]);
        
        if (typeA == "豹子" && typeB != "豹子") {
            cout << "Eric" << endl;
        } else if (typeA != "豹子" && typeB == "豹子") {
            cout << "Computer" << endl;
        } else if (typeA == "豹子" && typeB == "豹子") {
            if (a[2] > b[2]) {
                cout << "Eric" << endl;
            } else if (a[2] < b[2]) {
                cout << "Computer" << endl;
            } else {
                cout << "Balance" << endl;
            }
        } else if (typeA == "对子" && typeB != "对子") {
            cout << "Eric" << endl;
        } else if (typeA != "对子" && typeB == "对子") {
            cout << "Computer" << endl;
        } else if (typeA == "对子" && typeB == "对子") {
            if (a[2] > b[2]) {
                cout << "Eric" << endl;
            } else if (a[2] < b[2]) {
                cout << "Computer" << endl;
            } else {
                cout << "Balance" << endl;
            }
        } else if (typeA == "点子" && typeB == "点子") {
            int sumA = a[0] + a[1] + a[2];
            int sumB = b[0] + b[1] + b[2];
            if (sumA > sumB) {
                cout << "Eric" << endl;
            } else if (sumA < sumB) {
                cout << "Computer" << endl;
            } else {
                cout << "Balance" << endl;
            }
        }
    }
    
    return 0;
}

求助民间的大佬!!!

2023/10/22 10:52
加载中...