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 }



  • 相关阅读:
    对List进行子查询及分组
    网格数据库架构设计构想
    推荐一款简单实用的漏洞测试工具:Paros
    用友U9产品SOA设计架构遭技术质疑
    超简单使用MemCached
    不按常规出招
    如何学好AJax、求高手指点
    Begin
    SpringBoot基础
    SpringBoot基础学习(番外9.1)Spring MVC或Spring Boot配置默认访问页面不生效?
  • 原文地址:https://www.cnblogs.com/zllwxm123/p/11191666.html
Copyright © 2011-2022 走看看