zoukankan      html  css  js  c++  java
  • HDU 2164(模拟)

    Rock, Paper, or Scissors?

    Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
    Total Submission(s): 2927    Accepted Submission(s): 1873


    Problem Description
    Rock, Paper, Scissors is a two player game, where each player simultaneously chooses one of the three items after counting to three. The game typically lasts a pre-determined number of rounds. The player who wins the most rounds wins the game. Given the number of rounds the players will compete, it is your job to determine which player wins after those rounds have been played.

    The rules for what item wins are as follows:

    ?Rock always beats Scissors (Rock crushes Scissors)
    ?Scissors always beat Paper (Scissors cut Paper)
    ?Paper always beats Rock (Paper covers Rock)
     
    Input
    The first value in the input file will be an integer t (0 < t < 1000) representing the number of test cases in the input file. Following this, on a case by case basis, will be an integer n (0 < n < 100) specifying the number of rounds of Rock, Paper, Scissors played. Next will be n lines, each with either a capital R, P, or S, followed by a space, followed by a capital R, P, or S, followed by a newline. The first letter is Player 1抯 choice; the second letter is Player 2抯 choice.

     
    Output
    For each test case, report the name of the player (Player 1 or Player 2) that wins the game, followed by a newline. If the game ends up in a tie, print TIE.
     
    Sample Input
    3 2 R P S R 3 P P R S S R 1 P R
     
    Sample Output
    Player 2 TIE Player 1
    #include <iostream>
    #include<cstdio>
    using namespace std;
    
    int main()
    {
        int t;
        int n;
        char c1,c2;
        int s1,s2;
        scanf("%d",&t);
        while(t--)
        {
            s1=s2=0;//!!注意初始化位置
            scanf("%d",&n);
            getchar();//
            while(n--)
            {
                scanf("%c %c",&c1,&c2);
                getchar();//
                if(c1==c2) continue;
                else if(c1=='R'&&c2=='S'||c1=='S'&&c2=='P'||c1=='P'&&c2=='R')
                {
                    s1++;
                }
                else
                    s2++;
            }
                if(s1==s2) printf("TIE
    ");
                else if(s1>s2)  printf("Player 1
    ");
                else  printf("Player 2
    ");
        }
        return 0;
    }
    

      

  • 相关阅读:
    Linux 线程间通信方式+进程通信方式 总结
    使用opencv第三方库的makefile文件示例
    rplidar SDK 二次开发---之获取目标信息(0.1)
    #include "Target_orientation.h"
    opencv —— 调用摄像头采集图像 VideoCapture capture(0);
    cmake 支持-lpthread
    ROS下sensor_msgs::ImagePtr到sensor_msgs::Image之间的转换
    JAVA 校验身份证号码工具类(支持15位和18位)
    python面向对象游戏练习:好人坏人手枪手榴弹
    python 私有属性的作用
  • 原文地址:https://www.cnblogs.com/Roni-i/p/7220277.html
Copyright © 2011-2022 走看看