描述

Rock, Paper, Scissors is a classic hand game for two people. Each participant holds out either a fist (rock), open hand (paper), or two-finger V (scissors). If both players show the same gesture, they try again. They continue until there are two different gestures. The winner is then determined according to the table below: Rock beats Scissors    Paper beats Rock   
Scissors beats Paper  Your task is to take a list of symbols representing the gestures of two players and determine how many games each player wins. In the following example:

Turn     : 1 2 3 4 5

Player 1 : R R S R S

Player 2 : S R S P S

Player 1 wins at Turn 1 (Rock beats Scissors), Player 2 wins at Turn 4 (Paper beats Rock), and all the other turns are ties.

输入

The input contains between 1 and 20 pairs of lines, the first for Player 1 and the second for Player 2. Both player lines contain the same number of symbols from the set {'R', 'P', 'S'}. The number of symbols per line is between 1 and 75, inclusive.  A pair of lines each containing the single character 'E' signifies the end of the input.

输出

For each pair of input lines, output a pair of output lines as shown in the sample output, indicating the number of games won by each player.

样例输入

RRSRS

SRSPS

PPP

SSS

SPPSRR

PSPSRS

E

E

样例输出

P1: 1

P2: 1

P1: 0

P2: 3

P1: 2

P2: 1

#include<iostream>
#include<string>
using namespace std; void compare(char a,char b,int &count1,int &count2)
{
if(a=='R')
{
if(b=='S') count1++;
if(b=='P') count2++;
}
if(a=='P')
{
if(b=='R') count1++;
if(b=='S') count2++;
}
if(a=='S')
{
if(b=='P') count1++;
if(b=='R') count2++;
}
}
int main()
{
string s1,s2;
while(cin>>s1>>s2&&(s1!="E"&&s2!="E"))
{
int len=s1.length();
int i;
int count1=0;
int count2=0;
for(i=0;i<len;i++)
{
compare(s1[i],s2[i],count1,count2);
}
cout<<"P1: "<<count1<<endl;
cout<<"P2: "<<count2<<endl;
}
return 0;
}

  

1090-Rock, Paper, Scissors的更多相关文章

  1. 2018 ACM-ICPC 中国大学生程序设计竞赛线上赛 H题 Rock Paper Scissors Lizard Spock.(FFT字符串匹配)

    2018 ACM-ICPC 中国大学生程序设计竞赛线上赛:https://www.jisuanke.com/contest/1227 题目链接:https://nanti.jisuanke.com/t ...

  2. SDUT 3568 Rock Paper Scissors 状压统计

    就是改成把一个字符串改成三进制状压,然后分成前5位,后5位统计, 然后直接统计 f[i][j][k]代表,后5局状压为k的,前5局比和j状态比输了5局的有多少个人 复杂度是O(T*30000*25*m ...

  3. FFT(Rock Paper Scissors Gym - 101667H)

    题目链接:https://vjudge.net/problem/Gym-101667H 题目大意:首先给你两个字符串,R代表石头,P代表布,S代表剪刀,第一个字符串代表第一个人每一次出的类型,第二个字 ...

  4. Gym - 101667H - Rock Paper Scissors FFT 求区间相同个数

    Gym - 101667H:https://vjudge.net/problem/Gym-101667H 参考:https://blog.csdn.net/weixin_37517391/articl ...

  5. Gym101667 H. Rock Paper Scissors

    将第二个字符串改成能赢对方时对方的字符并倒序后,字符串匹配就是卷积的过程. 那么就枚举字符做三次卷积即可. #include <bits/stdc++.h> struct Complex ...

  6. 【题解】CF1426E Rock, Paper, Scissors

    题目戳我 \(\text{Solution:}\) 考虑第二问,赢的局数最小,即输和平的局数最多. 考虑网络流,\(1,2,3\)表示\(Alice\)选择的三种可能性,\(4,5,6\)同理. 它们 ...

  7. 题解 CF1426E - Rock, Paper, Scissors

    一眼题. 第一问很简单吧,就是每个 \(\tt Alice\) 能赢的都尽量让他赢. 第二问很简单吧,就是让 \(\tt Alice\) 输的或平局的尽量多,于是跑个网络最大流.\(1 - 3\) 的 ...

  8. HDOJ(HDU) 2164 Rock, Paper, or Scissors?

    Problem Description Rock, Paper, Scissors is a two player game, where each player simultaneously cho ...

  9. HDU 2164 Rock, Paper, or Scissors?

    http://acm.hdu.edu.cn/showproblem.php?pid=2164 Problem Description Rock, Paper, Scissors is a two pl ...

随机推荐

  1. EPP3怎么安装SVN(EclipsePHP Studio 3.0)

    如果你和我一样,喜欢用eclipse,你想用用他来开发PHP,那么EPP是一个不错的选择(个人觉得,中文版的有点不习惯) 我们一般都用svn来进行版本控制和代码共享,但是用epp3的时候会遇到这么一个 ...

  2. C# IO操作(三)文件编码

    在.net环境下新建一个文本文件(所谓文本文件就是直接可以用记事本打开的文件,直接保存字符串)和在系统中新建一个文本文件的编码是不一样的,.net默认采用UTF-8,而中文操作系统采用的是ANSI.如 ...

  3. WCF编程系列(七)信道及信道工厂

    WCF编程系列(七)信道及信道工厂   信道及信道栈 前面已经提及过,WCF中客户端与服务端的交互都是通过消息来进行的.消息从客户端传送到服务端会经过多个处理动作,在WCF编程模型中,这些动作是按层 ...

  4. selenium文件上传的实现

    一.对于上传文件, 从手动操作我们可以看出, 需要对window 窗体进行操作, 而对于selenium webdriver 在这方面应用就受到了限制. 但是, 庆幸的是, 对于含有input ele ...

  5. 几个动画demo

    一.点击扩散效果 这个效果没什么难度,主要是加深对核心动画的理解和使用,但是还是有几个想说明的地方.先看一下效果,具体内容代码里有注释. // // CircleButton.m // UITest ...

  6. html元素类型 块级元素、内联元素(又叫行内元素)和内联块级元素。

    html中的标签元素大体被分为三种不同的类型:块级元素.内联元素(又叫行内元素)和内联块级元素. 块级元素特点: 1.每个块级元素都从新的一行开始,并且其后的元素也另起一行.(霸道,一个块级元素独占一 ...

  7. Java架构必会几大技术点(转)

    关于学习架构,必须会的几点技术: 1. java反射技术 2. xml文件处理 3. properties属性文件处理 4. 线程安全机制 5. annocation注解 6. 设计模式 7. 代理机 ...

  8. mysql学习笔记4

    用phpmyadmin创建数据库时出现 #1064 - You have an error in your SQL syntax; check the manual that corresponds ...

  9. [java学习笔记]JDK的安装和环境变量的配置

    1.JDK的下载和安装 jdk(java development kit)是java提供给我们的一套java开发工具,它必运行在JVM(java虚拟机)上,java语言的跨平台性就是利用java运行在 ...

  10. 实习笔记-1:sql 2008r2 如何创建定时作业

    在公司实习了近一个月,学了很多东西.这一篇是一些比较基础的东西,本人是小菜鸟,不喜欢大神来喷.大神欢迎出门点右上角.谢谢~ 说大实话,对于数据库,我在还没出来实习的时候就是只懂写一些sql语句以及知道 ...