zoukankan      html  css  js  c++  java
  • 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 }
  • 相关阅读:
    python读写操作excel数据
    python读写操作excel数据小应用
    操作系统相关知识
    网络编程课堂笔记
    UDP简单初识+socketserver 模块实现服务端并发
    链接循环+模拟远程执行命令+实现大文件上传
    循环通信
    luogu P2761 软件补丁问题
    luogu P4016 负载平衡问题
    P3381 【模板】最小费用最大流(spfa板子)
  • 原文地址:https://www.cnblogs.com/zzw1024/p/11294526.html
Copyright © 2011-2022 走看看