题目描述
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.
大侦探福尔摩斯接到一张奇怪的字条:我们约会吧!3485djDkxh4hhGE 2984akDfkkkkggEdsb s&hgsfdk d&Hyscvnm。
大侦探很快就明白了,字条上奇怪的乱码实际上就是约会的时间星期四 14:04,因为前面两字符串中第 1 对相同的大写英文字母(大小写有区分)是第 4 个字母 D,代表星期四;第 2 对相同的字符是 E ,那是第 5 个英文字母,代表一天里的第 14 个钟头(于是一天的 0 点到 23 点由数字 0 到 9、以及大写字母 A 到 N 表示);后面两字符串第 1 对相同的英文字母 s 出现在第 4 个位置(从 0 开始计数)上,代表第 4 分钟。
现给定两对字符串,请帮助福尔摩斯解码得到约会的时间。
补充
1、一对字符相同,是指在两个字符相同且在字符串的位置也相同。
2、前两个字符串中第一对相同的大写英文字母,是指第一对能够正确代表日期的大写英文字母。
3、前两个字符串中第二对相同的字符,是指位于代表日期的字符后面的,第一对相同的,能够正确代表小时的字符。
输入格式
输入在 4 行中分别给出 4 个非空、不包含空格、且长度不超过 60 的字符串。
输出格式
在一行中输出约会的时间,格式为 DAY HH:MM,其中 DAY 是某星期的 3 字符缩写,即 MON 表示星期一,TUE 表示星期二,WED 表示星期三,THU 表示星期四,FRI 表示星期五,SAT 表示星期六,SUN 表示星期日。
题目输入保证每个测试存在唯一解。
Sample Input:
3485djDkxh4hhGE
2984akDfkkkkggEdsb
s&hgsfdk
d&Hyscvnm
Sample Output:
THU 14:04
//referring to指; 关于;提及;参阅
// It took him only a minute to figure out that
//those strange strings are actually referring to the coded time Thursday 14:04
//他只花了一分钟就弄清楚那些奇怪的字符串实际上是指星期四14:04的编码时间
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
string a,b,c,d;
cin>>a>>b>>c>>d;
int k = 0;
while(true)
{
if(a[k] == b[k] && a[k] >= 'A' && a[k] <= 'G') break;
k++;
}
char weekdays[7][4] = {"MON","TUE","WED","THU","FRI","SAT","SUN"};
printf("%s ",weekdays[a[k]-'A']);
k++;
while(true)
{
if(a[k]==b[k] && (a[k]>='0' && a[k]<='9' || a[k]>='A' && a[k]<='N')) break;
k++;
}
printf("%02d:",a[k]<='9' ? a[k]-'0': a[k]-'A'+10);
for(int i = 0; ; i++)
if(c[i] == d[i] && (c[i]>='a' && c[i]<='z'|| c[i]>='A' && c[i]<='Z'))
{
printf("%02d\n",i);
break;
}
return 0;
}