1.7.04 stone scissors cloth (character array), 1.7.04 Array
04: Stone scissors
-
Total time limit:
-
1000 ms
-
Memory limit:
-
65536kB
-
Description
-
Stone scissors are a guessing game. It originated in China and then spread to Japan, North Korea, and other places. With the continuous development of Asia-Europe trade, it spread to Europe and gradually swept the world in modern times. Simple and clear rules make stone scissors free from any rules and vulnerabilities to be drilled. Single gameplay matches luck and multiple rounds of gameplay matches the psychological game, this ancient game, stone scissors, is also used in two features: "unexpected" and "technology", and is favored by the people of the world.
Game Rules: Stone scissors, cloth bag stone, scissors.
Now, you need to write a program to determine the result of the stone scissors game.
-
Input
-
The input includes N + 1 rows:
The first line is an integer N, indicating that a total of N games were played. 1 <= N <= 100.
Each row of the next N rows contains two strings, indicating the choice of the game participant Player1 and Player2 (stone, scissors, or cloth ):
S1 S2
String S1 is separated by spaces. S2 can only be set to {"Rock", "Scissors", "Paper"} (case sensitive.
-
Output
-
The output includes N rows. Each row corresponds to a winner (Player1 or Player2), or the Tie is output when the game draws.
-
Sample Input
-
3Rock ScissorsPaper PaperRock Paper
-
Sample output
-
Player1TiePlayer2
-
Prompt
-
Rock is a stone, Scissors is a Scissors, and Paper is a cloth.
#include<stdio.h>int main(){ int i,n; char s1[10],s2[10]; int s[101]; scanf("%d",&n); getchar(); for(i=0;i<n;++i) { scanf("%s%s",s1,s2); if(s1[0]==s2[0]) s[i]=0; switch(s1[0]) { case 'R': if (s2[0]=='S') s[i]=1; else if(s2[0]=='P') s[i]=2; break; case 'S': if (s2[0]=='R') s[i]=2; else if(s2[0]=='P') s[i]=1; break; case 'P': if (s2[0]=='R') s[i]=1; else if(s2[0]=='S') s[i]=2; break; } } for(i=0;i<n;++i) if(s[i]==0) printf("Tie\n"); else if (s[i]==1) printf("Player1\n"); else if(s[i]==2) printf("Player2\n"); return 0; }
View Code
-