04:石頭剪子布
- 總時間限制:
- 1000ms
- 內存限制:
- 65536kB
- 描述
-
石頭剪子布,是一種猜拳游戲。起源於中國,然后傳到日本、朝鮮等地,隨着亞歐貿易的不斷發展它傳到了歐洲,到了近現代逐漸風靡世界。簡單明了的規則,使得石頭剪子布沒有任何規則漏洞可鑽,單次玩法比拼運氣,多回合玩法比拼心理博弈,使得石頭剪子布這個古老的游戲同時用於“意外”與“技術”兩種特性,深受世界人民喜愛。
游戲規則:石頭打剪刀,布包石頭,剪刀剪布。
現在,需要你寫一個程序來判斷石頭剪子布游戲的結果。 - 輸入
-
輸入包括N+1行:
第一行是一個整數N,表示一共進行了N次游戲。1 <= N <= 100。
接下來N行的每一行包括兩個字符串,表示游戲參與者Player1,Player2的選擇(石頭、剪子或者是布):
S1 S2
字符串之間以空格隔開S1,S2只可能取值在{"Rock", "Scissors", "Paper"}(大小寫敏感)中。 - 輸出
- 輸出包括N行,每一行對應一個勝利者(Player1或者Player2),或者游戲出現平局,則輸出Tie。
- 樣例輸入
-
3 Rock Scissors Paper Paper Rock Paper
- 樣例輸出
-
Player1 Tie Player2
- 提示
- Rock是石頭,Scissors是剪刀,Paper是布。
思路:
大模擬,不解釋;
來,上代碼:
#include<cstdio> #include<string> #include<cstring> #include<iostream> using namespace std; int t; string word_1,word_2; int main() { scanf("%d",&t); while(t--) { cin>>word_1>>word_2; if(word_1[0]=='R') { if(word_2[0]=='R') printf("Tie\n"); if(word_2[0]=='P') printf("Player2\n"); if(word_2[0]=='S') printf("Player1\n"); } if(word_1[0]=='S') { if(word_2[0]=='S') printf("Tie\n"); if(word_2[0]=='R') printf("Player2\n"); if(word_2[0]=='P') printf("Player1\n"); } if(word_1[0]=='P') { if(word_2[0]=='P') printf("Tie\n"); if(word_2[0]=='S') printf("Player2\n"); if(word_2[0]=='R') printf("Player1\n"); } } return 0; }