2 solutions
-
2
#include<bits/stdc++.h> using namespace std; int main() { int a; cin>>a; for(int n=1;n<=a;n++){ string Player1,Player2; cin>>Player1>>Player2; if (Player1=="Rock"){ if(Player2=="Rock"){ cout<<"Tie"; cout<<endl; } else if(Player2=="Scissors"){ cout<<"Player1"; cout<<endl; } else{ cout<<"Player2"; cout<<endl; } }//如果一号玩家出石头 else if(Player1=="Scissors"){ if(Player2=="Rock"){ cout<<"Player2"; cout<<endl; } else if(Player2=="Scissors"){ cout<<"Tie"; cout<<endl; } else{ cout<<"Player1"; cout<<endl; } } else { if(Player2=="Rock"){ cout<<"Player1"; cout<<endl; } else if(Player2=="Scissors"){ cout<<"Player2"; cout<<endl; } else{ cout<<"Tie"; cout<<endl; } } } return 0; }
-
0
#include<bits/stdc++.h> using namespace std; int main() { int n; cin>>n; for(int i=1;i<=n;i++) { string a,b; cin>>a>>b; if(a=="Rock"&&b=="Scissors"||a=="Scissors"&&b=="Paper"||a=="Paper"&&b=="Rock") { cout<<"Player1"<<endl; } else if(a=="Rock"&&b=="Rock"||a=="Scissors"&&b=="Scissors"||a=="Paper"&&b=="Paper") { cout<<"Tie"<<endl; } else { cout<<"Player2"<<endl; } } return 0; }
- 1
Information
- ID
- 2143
- Time
- 1000ms
- Memory
- 128MiB
- Difficulty
- 1
- Tags
- (None)
- # Submissions
- 17
- Accepted
- 8
- Uploaded By