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

    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 #define _CRT_SECURE_NO_WARNINGS
     2 #include <climits>
     3 #include<iostream>
     4 #include<vector>
     5 #include<queue>
     6 #include<map>
     7 #include<set>
     8 #include<stack>
     9 #include<algorithm>
    10 #include<string>
    11 #include<cmath>
    12 using namespace std;
    13 string Weeks[7] = { "MON","TUE","WED","THU","FRI","SAT","SUN" };
    14 int main()
    15 {
    16     string s1, s2,s3,s4;
    17     cin >> s1 >> s2 >> s3 >> s4;
    18     int length1 = s1.length();
    19     int length2 = s2.length();
    20     int i = 0;
    21     int h = 0, m = 0;
    22     int flag = 0;
    23     int week = 0;
    24     while (i<length1&&i<length2)
    25     {
    26         if (flag == 0)
    27         {
    28             if (s1.at(i) == s2.at(i) && (s1.at(i) >= 'A' && s1.at(i) <= 'G'))
    29             {
    30                 week = s1.at(i) - 'A';
    31                 flag++;
    32             }
    33         }
    34         else if (flag == 1)
    35         {
    36             if (s1.at(i) == s2.at(i)&&((s1.at(i) >= 'A' && s1.at(i) <= 'N')||isdigit(s1.at(i)))){
    37                 h = (s1.at(i) >= '0' && s1.at(i) <= '9') ? s1.at(i) - '0' : s1.at(i) - 'A' + 10;
    38                 break;
    39             }
    40         }
    41         i++;
    42     }
    43     i =0;
    44     length1 = s3.length();
    45     length2 = s4.length();
    46     while (i < length1&&i<length2)
    47     {
    48         if (s3.at(i) == s4.at(i)&&((s3.at(i)>='a'&&s3.at(i)<='z')||(s3.at(i)>='A'&&s3.at(i)<='Z')))
    49         {
    50             m = i;
    51             break;
    52         }
    53         i++;
    54     }
    55     cout<< Weeks[week];
    56     printf(" %02d:%02d", h, m);
    57 }
    View Code
  • 相关阅读:
    模拟信号的优缺点分析
    PLC控制网关的功能介绍及应用领域
    LoRa无线数传终端的优势
    串口服务器厂家哪家好
    串口转以太网转换器的工作模式
    一个能手机控制水泵的无线远程开关控制器
    以太网IO模块是什么
    支持MQTT的模块有哪些
    常用正交表
    Spring Boot源码(五)以HttpEncodingAutoConfiguration【Http 编码自动配置】为例解释自动配置原理
  • 原文地址:https://www.cnblogs.com/57one/p/12055642.html
Copyright © 2011-2022 走看看