1061. Dating (20)

来源:互联网 发布:excel矩阵相乘value 编辑:程序博客网 时间:2024/05/16 14:03
  1. Dating (20)
    时间限制
    150 ms
    内存限制
    65536 kB
    代码长度限制
    16000 B
    判题程序
    Standard
    作者
    CHEN, Yue
    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

AC代码:

#include <iostream>#include <cstdio>#include <cstring>using namespace std;int main(void){    char a[61], b[61], c[61], d[61];    cin >> a >> b >> c >> d;    char re1, re2;    int re3;    int l1 = strlen(a), l2 = strlen(b), l3 = strlen(c), l4 = strlen(d);    int i, j, t = 0;;    for (i = 0; i < min(l1, l2); i++)    {        if (t == 2) break;            if (a[i] == b[i])            {                if (t == 1)                {                    if ((a[i] >= 'A' && a[i] <= 'N') || (a[i] >= '0' && a[i] <= '9'))                    {                        re2 = a[i];                        t++;                    }                }                if (t == 0)                {                    if (a[i] >= 'A' && a[i] <= 'G')                    {                        re1 = a[i];                        t++;                    }                }            }    }    for (i = 0; i < min(l3, l4); i++)    {        if (c[i] == d[i])        {            if ((c[i] >= 'A' && c[i] <= 'Z') || (c[i] >= 'a' && c[i] <= 'z'))            {                re3 = i;                break;            }        }    }    if (re1 - 'A' == 0) printf("MON ");    if (re1 - 'A' == 1) printf("TUE ");    if (re1 - 'A' == 2) printf("WED ");    if (re1 - 'A' == 3) printf("THU ");    if (re1 - 'A' == 4) printf("FRI ");    if (re1 - 'A' == 5) printf("SAT ");    if (re1 - 'A' == 6) printf("SUN ");    if (re2 >= '0' && re2 <= '9')    {        printf("%02d:", re2 - 48);    }    else    {        printf("%02d:", re2 - 'A' + 10);    }    printf("%02d", re3);}

这里写图片描述