当前位置:网站首页>1132: stone scissors cloth
1132: stone scissors cloth
2022-06-30 14:49:00 【I would, I think】
Method 1 : Two dimensional array
#include<iostream>
using namespace std;
int w[4][4];
int mmm(char x1[])
{
switch(x1[0])
{
case 'R':
return 1;
case 'S':
return 2;
case 'P':
return 3;
}
}
void mmm2()
{
w[1][1]=w[2][2]=w[3][3]=0;
w[1][2]=w[2][3]=w[3][1]=1;
w[2][1]=w[3][2]=w[1][3]=-1;
}
int main()
{
mmm2();
char S1[100],S2[100];
int n1,n2;
int N;
cin>>N;
for(int i=0;i<N;i++)
{
cin>>S1>>S2;
n1=mmm(S1);// If S1 by Rock, be S[0] by R, all n1=1
n2=mmm(S2);
if(w[n1][n2]==0)
{
cout<<"Tie"<<endl;
}
else if(w[n1][n2]==1)
{
cout<<"Player1"<<endl;
}
else
{
cout<<"Player2"<<endl;
}
}
return 0;
} Method 2 :string class
#include<iostream>
using namespace std;
int main()
{
int N;
cin>>N;
string S1;
string S2;
for(int i=1;i<=N;i++)
{
cin>>S1>>S2;
if(S1=="Rock"&&S2=="Scissors")
{
cout<<"Player1"<<endl;
}
else if(S1=="Scissors"&&S2=="Paper")
{
cout<<"Player1"<<endl;
}
else if(S1=="Paper"&&S2=="Rock")
{
cout<<"Player1"<<endl;
}
else if(S1==S2)
{
cout<<"Tie"<<endl;
}
else
{
cout<<"Player2"<<endl;
}
}
return 0;
}边栏推荐
- 数控加工中心打刀缸工作原理及故障处理
- Hbuilder most commonly used and full shortcut key set
- How many questions can you answer for the interview of Mechanical Engineer?
- catkin_ Make reports an error, transfers the location of the workspace, and uses other people's workspace files to cause compilation errors
- The first dark spring cup dnuictf
- [extensive reading of papers] multimodal attribute extraction
- Non decreasing column
- Detailed explanation of settimeout() and setinterval()
- CCF string matching (Full Score code + problem solving ideas + skill summary) March 3, 2014
- Minimum covering substring of two pointers
猜你喜欢

Ctfshow getting started with the web (ThinkPHP topic)

Knowledge learned from the water resources institute project

2021-05-12

CCF image rotation (Full Score code + problem solving idea) 201503-01

ThinkPHP show method parameter controllable command execution

DefCamp Capture the Flag (D-CTF) 2021-22 web
![[buuctf] [actf2020 freshman competition]exec1](/img/af/22051a5feb3c1f6d7201a483bde127.jpg)
[buuctf] [actf2020 freshman competition]exec1
![[buuctf] [geek challenge 2019] secret file](/img/00/23bebd013eb4035555c0057725e3c4.jpg)
[buuctf] [geek challenge 2019] secret file

LIS error: this configuration section cannot be used in this path

XSS challenge (1-5) more detailed answers
随机推荐
Problem: wechat developer tool visitor mode cannot use this function
Thinkphp5 log file contains trick
Lfi-rce without controllable documents
val_ Loss decreases first and then increases or does not decrease but only increases
JS time conversion standard format, timestamp conversion standard format
NoViableAltException([email protected][])
Laravel artist command error
ES6 notes
Text matching - [naacl 2021] augsbert
Win10 backup backup shows that creating a shared protection point on the shadow failed
August 24, 2021 deque queue and stack
K high frequency elements before sorting
The difference between settimeout() and setinterval()
數據恢複軟件EasyRecovery15下載
Basic learning notes of C language
IO interview questions
ctfshow nodejs
Logiciel de récupération de données easyrecovery15 téléchargement
这种零件该怎么编程加工?
Laravel RBAC laravel permission use