T1106 stone scissors cloth
Title description
Rock-paper-scissors is 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. The simple and clear rules make the rock-paper-scissors cloth have no loopholes to be drilled. Single-time gameplay compares luck, and multi-round gameplay compares psychological games. This ancient game of rock-paper-scissors cloth is used for both "accident" and "technical" characteristics , Loved by people all over the world.
Game rules: Rock-to-play scissors, cloth-covered rocks, scissors and cloth.
Now, you need to write a program to judge the result of the rock-paper-scissors game.
Input format
The input consists of N+1 lines:
The first line is an integer N, which means that a total of N games have been played. 1≤N≤100.
Each of the next N lines contains two strings, representing the choice of game participants "Player1" and "Player2" (stone, scissors or cloth):
S1 S2The strings are separated by spaces S1, S2 can only take values in {"Rock", "Scissors", "Paper"} (case sensitive).
Output format
The output includes N lines, and each line corresponds to a winner "Player1" or "Player2", or if the game is tied, then "Tie" is output.
Sample input
3
Rock Scissors
Paper Paper
Rock Paper
Sample output
Player1
Tie
Player2
Code
#include <iostream>
#include <string>
using namespace std;
int main(){
int N;
char S1[20], S2[20];
string Winner[105];
cin >> N;
for(int i=0; i<N; i++){
cin >> S1;
cin >> S2;
if((S1[0]=='R' && S2[0]=='S') || (S1[0]=='S' && S2[0]=='P') || (S1[0]=='P' && S2[0]=='R'))
Winner[i] = "Player1";
else if(S1[0] == S2[0])
Winner[i] = "Tie";
else
Winner[i] = "Player2" ;
}
for(int i=0; i<N; i++)
cout << Winner[i] << endl;
return 0;
}