简单模拟-----PAT乙级1018 锤子剪刀布

AC代码

#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int change(char c)
{
    if(c=='B')
    {
        return 0;
    }
    else if(c=='C')
    {
        return 1;
    }
    else
    {
        return 2;
    }
}
int main()
{
    char mp[3]={'B','C','J'};
    int n;
    cin>>n;
    int time_A[3]={0},time_B[3]={0};
    int hand_A[3]={0},hand_B[3]={0};
    char c1,c2;
    int  k1,k2;
    while(n--)
    {
        getchar();
        cin>>c1>>c2;
        k1=change(c1);
        k2=change(c2);
        if((k1+1)%3==k2)
        {
            time_A[0]++;
            time_B[2]++;
            hand_A[k1]++;
        }
        else if(k1==k2)
        {
            time_A[1]++;
            time_B[1]++;
        }
        else
        {
            time_A[2]++;
            time_B[0]++;
            hand_B[k2]++;
        }
    }
    cout<<time_A[0]<<" "<<time_A[1]<<" "<<time_A[2]<<endl;
    cout<<time_B[0]<<" "<<time_B[1]<<" "<<time_B[2]<<endl;
    int id1=0,id2=0;
    for(int i=0;i<3;i++)
    {
        if(hand_A[i]>hand_A[id1])
        {
            id1=i;
        }
        if(hand_B[i]>hand_B[id2])
        {
            id2=i;
        }
    }
    cout<<mp[id1]<<" "<<mp[id2]<<endl;
    return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值