#include<iostream>
using namespace std;
int main(){
int n;
cin >> n;
while(n--){
string s1,s2;
cin >> s1 >> s2;
if(s1 == s2)
cout << "Tie" << endl;
else if(s1 == "Hunter"){
if(s2 == "Bear")
cout << "Player2" << endl;
else
cout << "Player1" << endl;
}
else if(s1 == "Gun"){
if(s2 == "Hunter")
cout << "Player2" << endl;
else
cout << "Player1" << endl;
}
else{
if(s2 == "Hunter")
cout << "Player1" << endl;
else
cout << "Player2" << endl;
}
}
return 0;
}
取模运算进行比较,比判断比较要快
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
int n;
cin >> n;
while(n--){
string a,b;
cin >> a >> b;
int x,y;
if(a == "Hunter")
x = 0;
else if(a == "Bear")
x = 1;
else
x = 2;
if(b == "Hunter")
y = 0;
else if(b == "Bear")
y = 1;
else
y = 2;
if(x == y)
puts("Tie");
else if(x == (y + 1) % 3)
puts("Player1");
else
puts("Player2");
}
return 0;
}