zoukankan      html  css  js  c++  java
  • 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;
    }
    


    每天训练发现我比别人做的好慢,但是理解的更深刻,如果一开始学一个新知识点就搜模板,那么这样的人是走不远的,毕业之后带走的只有思维,什么荣誉,奖杯都已经不重要了。
  • 相关阅读:
    熟悉常用的HDFS操作
    爬虫爬取小说网站
    数据结构化与保存
    使用正则表达式,取得点击次数,函数抽离
    爬取校园新闻首页的新闻
    网络爬虫基础练习
    综合练习:词频统计
    最近在学习多元分析,有空放上来分享
    机器学习基石作业一15-20题(Python实现)
    2018十月份
  • 原文地址:https://www.cnblogs.com/6bing/p/3931251.html
Copyright © 2011-2022 走看看