Two teams meet in The Game World Championship. Some scientists consider this game to be the most intellectually challenging game in the world. You are given two strings describing the teams' actions in the final battle. Figure out who became the champion.
Input
The input contains two strings of equal length (between 2 and 20 characters, inclusive). Each line describes the actions of one team.
Output
Output "TEAM 1 WINS" if the first team won, "TEAM 2 WINS" if the second team won, and "TIE" if there was a tie.
题意:[]代表布,()代表石头,8<代表剪刀
输出哪个队赢
Sample test(s)
input
[]()[]8< 8<[]()8<
output
TEAM 2 WINS
input
8<8<() []8<[]
output
TIE
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
int main()
{
string s1,s2;
cin>>s1;
cin>>s2;
int count1=0,count2=0;
for(int i=0;i<s1.size();i+=2)
{
if(s1[i]==s2[i])
{
count1++;
count2++;
}
else if(s1[i]=='8'&&s2[i]!='8')
{
if(s2[i]=='[')
count1++;
else if(s2[i]=='(')
count2++;
}
else if(s1[i]=='['&&s2[i]!='[')
{
if(s2[i]=='8')
count2++;
else if(s2[i]=='(')
count1++;
}
else if(s1[i]=='('&&s2[i]!='(')
{
if(s2[i]=='8')
count1++;
else if(s2[i]=='[')
count2++;
}
}
if(count1>count2)
cout<<"TEAM 1 WINS"<<endl;
else if(count1<count2)
cout<<"TEAM 2 WINS"<<endl;
else
cout<<"TIE"<<endl;
return 0;
}