zoukankan      html  css  js  c++  java
  • pat 1061. Dating (20)

    1061. Dating (20)

    时间限制
    50 ms
    内存限制
    65536 kB
    代码长度限制
    16000 B
    判题程序
    Standard
    作者
    CHEN, Yue

    Sherlock Holmes received a note with some strange strings: "Let's date! 3485djDkxh4hhGE 2984akDfkkkkggEdsb s&hgsfdk d&Hyscvnm". It took him only a minute to figure out that those strange strings are actually referring to the coded time "Thursday 14:04" -- since the first common capital English letter (case sensitive) shared by the first two strings is the 4th capital letter 'D', representing the 4th day in a week; the second common character is the 5th capital letter 'E', representing the 14th hour (hence the hours from 0 to 23 in a day are represented by the numbers from 0 to 9 and the capital letters from A to N, respectively); and the English letter shared by the last two strings is 's' at the 4th position, representing the 4th minute. Now given two pairs of strings, you are supposed to help Sherlock decode the dating time.

    Input Specification:

    Each input file contains one test case. Each case gives 4 non-empty strings of no more than 60 characters without white space in 4 lines.

    Output Specification:

    For each test case, print the decoded time in one line, in the format "DAY HH:MM", where "DAY" is a 3-character abbreviation for the days in a week -- that is, "MON" for Monday, "TUE" for Tuesday, "WED" for Wednesday, "THU" for Thursday, "FRI" for Friday, "SAT" for Saturday, and "SUN" for Sunday. It is guaranteed that the result is unique for each case.

    Sample Input:
    3485djDkxh4hhGE 
    2984akDfkkkkggEdsb 
    s&hgsfdk 
    d&Hyscvnm
    
    Sample Output:
    THU 14:04
    

    解:这题卡死,修改到心累,最后一组样例还是过不去,卧槽,是大写capital,我忘了这个单词什么意思,然后我在日期的判断上始终考虑大小写都可以的,呵呵哒,给自己跪了,看了那么长时间就卡这了,没什么弯子的一题,就卡死了,整理完睡觉去。

    代码:

    #include<iostream>
    #include<cstdlib>
    #include<cstdio>
    #include<cstring>
    using namespace std;
    
    char h1[7]={'A','B','C','D','E','F','G'};
    char h3[24]={'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','G','H','I','J','K','L','M','N'};
    char data[8][5]={"MON","TUE","WED","THU","FRI","SAT","SUN"};
    char hour[25][3]={"00","01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18","19","20","21","22","23"};
    
    int  main()
    {
        string s1,s2,s3,s4;
        while(cin>>s1>>s2>>s3>>s4)
        {
            string res;
            int len=min(s1.length(),s2.length());
            int flag=0;
            for(int i=0;i<len;i++)
            {
                if(flag==0&&s1[i]==s2[i]&&isalpha(s1[i]))
                {
                    for(int j=0;j<7;j++)
                    {
                        if(s1[i]==h1[j])
                        {
                            flag=1;
                            res+=data[j];
                            res+=" ";
                            break;
                        }
                    }
                    if(flag==1)
                        continue;
                }
                if(flag==1&&s1[i]==s2[i]&&isalnum(s1[i]))
                {
                    for(int j=0;j<24;j++)
                    {
                        if(s1[i]==h3[j])
                        {
                           res+=hour[j];
                           res+=":";
                           flag=2;
                           break;
                        }
                    }
                }
                if(flag==2)
                    break;
            }
            len=min(s3.length(),s4.length());
            for(int i=0;i<len;i++)
            {
                if(s3[i]==s4[i]&&isalpha(s3[i]))
                {
                   if(i<10)
                   {
                       res+="0";
                   }
                   char ss[6];
                   sprintf(ss,"%d",i);
                   res+=ss;
                   break;
                }
            }
            cout<<res<<endl;
        }
    }

    版权声明:本文为博主原创文章,未经博主允许不得转载。

  • 相关阅读:
    ADO.NET初学习
    phpstorm+xdeubg debugging 9000 is busy 提示端口不可以的处理办法
    mysql 乐观锁和悲观锁
    Laravel Facade 调用流程源码分析
    利用 反射ReflectionClass来查看里面的属性和方法
    PHP ArrayAccess 接口简单实例
    laravel service provider 简单实例
    从github 下载下来的PHP项目代码本地需要怎么部署
    PHP Closure 类的bind简介和使用
    PHP $this,self,static 的区别
  • 原文地址:https://www.cnblogs.com/Tobyuyu/p/4965294.html
Copyright © 2011-2022 走看看