April Fools Day Contest 2014--A

本文介绍了一个名为TheGreatGame的比赛,通过分析两个团队的动作字符串来判断胜负。输入为两行等长字符串,代表双方的动作(石头、剪刀、布),通过ASCII差值表示不同的动作。文章提供了一段C语言代码实现这一逻辑。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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;
}


转载于:https://www.cnblogs.com/6bing/p/3931251.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值