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

    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 #include <bits/stdc++.h>
     2 
     3 using namespace std;
     4 string s2, s1;
     5 string st1, st2;
     6 string an[7] ={"MON","TUE","WED","THU","FRI","SAT","SUN"};
     7 int a[5]={0};
     8 int main(){
     9     cin >> s1 >> s2 >> st1 >> st2;
    10     int pos = 0;
    11     for(int i = 0; i < min(s1.length(), s2.length()); i++){
    12         if(pos == 0 && s1[i] == s2[i] && s1[i] >= 'A' && s1[i] <= 'G'){
    13             a[pos] = s1[i] - 'A';
    14             pos++;
    15         }else if(pos == 1 && s1[i] == s2[i]){
    16             if(s1[i] >= 'A' && s1[i] <= 'N'){
    17                 a[pos] = s1[i] - 'A';
    18                 a[pos] += 10;
    19                 pos++;
    20             }else if(s1[i]>='0' && s1[i]<='9'){
    21                 a[pos] = s1[i] - '0';
    22                 pos++;
    23             }
    24         }else if(pos == 2){
    25             break;
    26         }
    27     }
    28 
    29     for(int i = 0; i < min(st1.length(), st2.length()); i++){
    30         if(st1[i] == st2[i] && isalpha(st1[i]) ){
    31             a[pos++] = i;
    32             break;
    33         }
    34     }
    35 
    36     cout <<an[a[0]]<<" ";
    37     printf("%02d:%02d
    ", a[1], a[2]);
    38     return 0;
    39 }



  • 相关阅读:
    JAVA消息对话框
    stringbuffer capacity()的疑问
    JAVA确认对话框
    c/c++实现获取NOD32升级账号密码
    复制构造函数(拷贝构造函数)
    使用VC将sqlite3.def转化为sqlite3.lib
    Windows下安装OpenSSL
    java中io与nio的使用
    使用 XStream 把 Java 对象序列化为 XML
    使用 XStream 把 Java 对象序列化为 XML
  • 原文地址:https://www.cnblogs.com/zllwxm123/p/11191666.html
Copyright © 2011-2022 走看看