Rock-paper-scissors 石头剪刀布

Time Limit: 2000MS Memory Limit: 262144K 64bit IO Format: %I64d& %I64u

[Submit [GoBack  [Status]

Description

Uncle Fyodor, Matroskin the Cat and Sharic the Dog live theirsimple but happy lives in Prostokvashino. Sometimes they receiveparcels from Uncle Fyodor’s parents and sometimes from anonymousbenefactors, in which case it is hard to determine to which one ofthem the package has been sent. A photographic rifle is obviouslyfor Sharic who loves hunting and fish is for Matroskin, but forwhom was a new video game console meant? Every one of the threefriends claimed that the present is for him and nearly quarreled.Uncle Fyodor had an idea how to solve the problem justly: theyshould suppose that the console was sent to all three of them andplay it in turns. Everybody got relieved but then yet anotherburning problem popped up — who will play first? This timeMatroskin came up with a brilliant solution, suggesting the mostfair way to find it out: play rock-paper-scissors together. Therules of the game are very simple. On the count of three everyplayer shows a combination with his hand (or paw). The combinationcorresponds to one of three things: a rock, scissors or paper. Someof the gestures win over some other ones according to well-knownrules: the rock breaks the scissors, the scissors cut the paper,and the paper gets wrapped over the stone. Usually there are twoplayers. Yet there are three friends, that’s why they decided tochoose the winner like that: If someone shows the gesture that winsover the other two players, then that player wins. Otherwise,another game round is required. Write a program that will determinethe winner by the gestures they have shown.

Input

The first input line contains the name of the gesture that UncleFyodor showed, the second line shows which gesture Matroskin showedand the third line shows Sharic’s gesture.

Output

Print "F" (without quotes) if Uncle Fyodor wins. Print "M" ifMatroskin wins and "S" if Sharic wins. If it is impossible to findthe winner, print "?".

Sample Input

Input
rock

rock

rock

Output
?

Input
paper

rock

rock

Output
F

Input
scissors

rock

rock

Output
?

Input
scissors

paper

rock

Output
?
可用判断字符串长度的方法(此题所给单词长度刚好都不一样!!)
#include<iostream>
using namespace std;
int main()
{
    char a[30],b[10],c[10],d[10];
                while(cin>>b>>c>>d)
                {
                        strcpy(a,b); strcat(a,c);strcat(a,d);
                        if(!strcmp(a,"rockscissorsscissors")||!strcmp(a,"scissorspaperpaper")||!strcmp(a,"paperrockrock"))
                        { cout<<"F"<<endl;continue;}
            if(!strcmp(a,"scissorsrockscissors")||!strcmp(a,"paperscissorspaper")||!strcmp(a,"rockpaperrock"))
                        {  cout<<"M"<<endl;continue;}
                if(!strcmp(a,"scissorsscissorsrock")||!strcmp(a,"paperpaperscissors")||!strcmp(a,"rockrockpaper"))
                          cout<<"S"<<endl;
                else cout<<"?"<<endl;     
                }
        return 0;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值