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


    每天训练发现我比别人做的好慢,但是理解的更深刻,如果一开始学一个新知识点就搜模板,那么这样的人是走不远的,毕业之后带走的只有思维,什么荣誉,奖杯都已经不重要了。
  • 相关阅读:
    【资源分享】一个匿名文件分享网站
    【C语言】指针到底有什么用
    【C语言】一招搞定C语言各种复杂指针
    【资源分享】Visual Studio全版本在线安装包(5MB)
    【资源分享】C语言也能干大事(第二版)
    【资源分享】迅雷
    Nuxt spa deploy
    nginx ssl docker
    Linux查看环境变量
    Nginx 配置
  • 原文地址:https://www.cnblogs.com/6bing/p/3931251.html
Copyright © 2011-2022 走看看