A. The Great Game
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
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.
Sample test(s)
Input
[]()[]8< 8<[]()8<
Output
TEAM 2 WINS
Input
8<8<() []8<[]
Output
TIE
意思:石头剪刀布 ()代表石头(ASCII 差 1), 8<代表 剪刀(ASCII 差 4) , [ ] 代表布(ASCII 差 2)———比如: ‘ [ ’ 的ASCII 与 ‘ ] ’ ASCII 相差 2
#include<stdio.h>
#include<string.h>
char s1[100], s2[100];
int main()
{
int i, j, count1=0, count2=0, len1 = 0, len2 = 0;
gets(s1);
gets(s2);
len1 = strlen(s1);
len2 = strlen(s2);
for(i=0; i<len1 -1; i+=2)
{
if(s1[i+1] - s1[i] == 2 && s2[i+1] - s2[i] == 4 || s1[i+1] - s1[i] == 1 && s2[i+1] - s2[i] == 2 || s1[i+1] - s1[i] == 4 && s2[i+1] - s2[i] == 1)
count2++;
if(s1[i+1] - s1[i] == 2 && s2[i+1] - s2[i] == 1 || s1[i+1] - s1[i] == 1 && s2[i+1] - s2[i] == 4 || s1[i+1] - s1[i] == 4 && s2[i+1] - s2[i] == 2)
count1++;
}
if(count1 == count2)
printf("TIE\n");
if(count1 > count2)
printf("TEAM 1 WINS\n");
if(count1 < count2)
printf("TEAM 2 WINS\n");
return 0;
}