• PAT甲级——A1061 Dating


    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
     1 #include <iostream>
     2 #include <string>
     3 using namespace std;
     4 int main()
     5 {
     6     string date[7] = { "MON","TUE","WED","THU","FRI","SAT","SUN" };
     7     string s1, s2, s3, s4;
     8     cin >> s1 >> s2 >> s3 >> s4;
     9     int flag = 0;
    10     for (int i = 0; i < s1.length() && i<s2.length(); ++i)
    11     {
    12         if (flag == 0 && s1[i] >= 'A' && s1[i] <= 'Z' && s1[i] == s2[i])
    13         {
    14             cout << date[s1[i] - 'A'] << " ";
    15             flag = 1;
    16         }
    17         else if(flag == 1 && s1[i] == s2[i] && ((s1[i] >= 'A' && s1[i] <= 'Z') || (s1[i] >= '0' && s1[i] <= '9')))
    18         {
    19             if (s1[i] >= '0'&& s1[i] <= '9')
    20                 cout << "0" << s1[i] - '0' << ":";
    21             else
    22                 cout << (s1[i] - 'A' + 10) << ":";
    23             break;
    24         }
    25     }
    26     int k = 0;
    27     for (int i = 0; i < s3.length() && i < s4.length(); ++i)
    28     {
    29         if (((s3[i] >= 'a' && s3[i] <= 'z') || (s3[i] >= 'A' && s3[i] <= 'Z')) && s3[i] == s4[i])
    30         {
    31             k = i;
    32             break;
    33         }
    34     }
    35     cout << (k > 9 ? "" : "0") << k << endl;
    36     return 0;
    37 }
  • 相关阅读:
    docker中centos7安装ssh服务
    redis加入systemctl服务
    elasticsearch设置执行脚本并添加开机启动 (转)
    CentOS7使用firewalld打开关闭防火墙与端口
    腾讯地图JSAPI开发demo 定位,查询
    C# 开发AliYun(阿里云) 小蜜调用接口代码
    VSCode 开发Core教程
    Rabbit原理理解
    Exceptionless 本地部署
    Visual Studio 2019 自带混淆工具DotFuscator不需要去网络下载
  • 原文地址:https://www.cnblogs.com/zzw1024/p/11294526.html
Copyright © 2020-2023  润新知