HDU-4461 The Power of Xiangqi 签到题

本博客介绍了一个简单的C++程序,用于计算两个输入值的和,并比较它们的大小。程序考虑了没有马或者炮的情况下能量减少1的情况,且确保能量不小于1。

题意:要求计算两个和值比较大小。注意没有马或者是炮的时候能量减1,且能量不能小于1。

代码如下:

#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
using namespace std;

int table[10] = {16, 7, 8, 1, 1, 2, 3};

int main() {
    int T;
    scanf("%d", &T);
    while (T--) {
        int x, y, sa = 0, sb = 0;
        char str[5];
        int m = 0, p = 0;
        scanf("%d", &x);
        for (int i = 0; i < x; ++i) {
            scanf("%s", str);
            sa += table[str[0]-'A'];
            if (str[0]-'A' == 1) m = 1;
            if (str[0]-'A' == 2) p = 1;
        }
        if (!m || !p) sa = max(1, sa - 1);
        m = p = 0;
        scanf("%d", &y);
        for (int i = 0; i < y; ++i) {
            scanf("%s", str);
            sb += table[str[0]-'A'];
            if (str[0]-'A' == 1) m = 1;
            if (str[0]-'A' == 2) p = 1;
        }
        if (!m || !p) sb = max(1, sb - 1);
        if (sa == sb) {
            puts("tie");
        } else {
            puts(sa > sb ? "red" : "black");
        }
    }
    return 0;    
} 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值