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
  • 相关阅读:
    python之简单窗口
    hdu1237简单计算器
    BST二叉查找树的实现与操作
    huffman树入门
    hdu2043密码
    hdu1870愚人节的礼物
    hdu 2085 核反应堆
    hdu 2066 一个人的旅行(Dijkstra求最短路问题)
    hdu 2063 过山车 (二分匹配)
    hdu 2067 小兔的棋盘(Catalan数)
  • 原文地址:https://www.cnblogs.com/57one/p/12055642.html
Copyright © 2011-2022 走看看