博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
HDU 2164(模拟)
阅读量:7136 次
发布时间:2019-06-28

本文共 2218 字,大约阅读时间需要 7 分钟。

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 
#include
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\n"); else if(s1>s2) printf("Player 1\n"); else printf("Player 2\n"); } return 0;}

  

转载于:https://www.cnblogs.com/Roni-i/p/7220277.html

你可能感兴趣的文章
myeclipse视图布局恢复
查看>>
2015 UESTC Training for Data Structures
查看>>
喜大普奔!开启我的博客之旅!
查看>>
Ubuntu相关的笔记
查看>>
session技术进行登录验证问题解析
查看>>
Linux 求某一列平均值
查看>>
【动态规划】Gym - 101102A - Coins
查看>>
【kd-tree】hdu5992 Finding Hotels
查看>>
【函数式权值分块】【分块】bzoj1901 Zju2112 Dynamic Rankings
查看>>
流程控制
查看>>
P4363 [九省联考2018]一双木棋chess(对抗搜索+记忆化搜索)
查看>>
execution plan in sqlserver
查看>>
【WCF之旅】第一回:概述
查看>>
设计模式(四)外观模式
查看>>
RadioGroup实现类似ios的分段选择(UISegmentedControl)控件
查看>>
51Nod 1079 中国剩余定理 Label:数论
查看>>
Spring aop练手
查看>>
Linux下安装SVN服务端
查看>>
Tomcat 部署项目的三种方法
查看>>
删数问题(贪心)
查看>>