1.7.04 stone scissors cloth (character array), 1.7.04 Array

Source: Internet
Author: User

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
 
 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.