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.第一次比对的是从’A’-‘G’之内的相同字母,其他任何字符相同的无效
2.第二次比对的是从’0’-‘9’及’A’-‘N’之内的相同字符,其他无效
吐槽下第一次用VS2005感觉比VS2012差了好几条街,根本没有智能提示,估计是我变成习惯不好,编译错了N次…但是免研的时候估计没那么新版本,还是适应一下吧~
============================================
#include
#include
#include
using namespace std;
const char* wkdays[] = {"MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN"};
int main()
{
const int BUFFER = 61;
char str1[BUFFER];
int results[3]; //存放四个数字结果
//第一次读取
cin >> str1;
int len1 = strlen(str1);
//第二次读取
char str2[BUFFER];
cin >> str2;
int len2 = strlen(str2);
int endIndex = (len1
continue;
}
else
{
if(chrIndex < 0 || chrIndex >= 14) //'N'
{
if(digIndex <0 || digIndex >9)
continue;
digitFlag = true;//是个数字
}
}
if(str1[i] == str2[i])
{
if(firstTime)
{
results[0] = chrIndex;
firstTime = false;
}
else
{
results[1] = digitFlag? (digIndex):(chrIndex + 10);
break;
}
}
}
//第三次读取
char str3[BUFFER];
char str4[BUFFER];
cin >> str3 >> str4;
int len3 = strlen(str3);
int len4 = strlen(str4);
endIndex = (len3