April Fools Day Contest 2014--A

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
");
if(count1 > count2)
     printf("TEAM 1 WINS
");
if(count1 < count2)
     printf("TEAM 2 WINS
");

	 return 0;
}


每天训练发现我比别人做的好慢,但是理解的更深刻,如果一开始学一个新知识点就搜模板,那么这样的人是走不远的,毕业之后带走的只有思维,什么荣誉,奖杯都已经不重要了。
原文地址:https://www.cnblogs.com/6bing/p/3931251.html