1061 Dating (20分)

Posted 57one

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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 #define _CRT_SECURE_NO_WARNINGS
 2 #include <climits>
 3 #include<iostream>
 4 #include<vector>
 5 #include<queue>
 6 #include<map>
 7 #include<set>
 8 #include<stack>
 9 #include<algorithm>
10 #include<string>
11 #include<cmath>
12 using namespace std;
13 string Weeks[7] = { "MON","TUE","WED","THU","FRI","SAT","SUN" };
14 int main()
15 {
16     string s1, s2,s3,s4;
17     cin >> s1 >> s2 >> s3 >> s4;
18     int length1 = s1.length();
19     int length2 = s2.length();
20     int i = 0;
21     int h = 0, m = 0;
22     int flag = 0;
23     int week = 0;
24     while (i<length1&&i<length2)
25     {
26         if (flag == 0)
27         {
28             if (s1.at(i) == s2.at(i) && (s1.at(i) >= A && s1.at(i) <= G))
29             {
30                 week = s1.at(i) - A;
31                 flag++;
32             }
33         }
34         else if (flag == 1)
35         {
36             if (s1.at(i) == s2.at(i)&&((s1.at(i) >= A && s1.at(i) <= N)||isdigit(s1.at(i)))){
37                 h = (s1.at(i) >= 0 && s1.at(i) <= 9) ? s1.at(i) - 0 : s1.at(i) - A + 10;
38                 break;
39             }
40         }
41         i++;
42     }
43     i =0;
44     length1 = s3.length();
45     length2 = s4.length();
46     while (i < length1&&i<length2)
47     {
48         if (s3.at(i) == s4.at(i)&&((s3.at(i)>=a&&s3.at(i)<=z)||(s3.at(i)>=A&&s3.at(i)<=Z)))
49         {
50             m = i;
51             break;
52         }
53         i++;
54     }
55     cout<< Weeks[week];
56     printf(" %02d:%02d", h, m);
57 }
View Code

以上是关于1061 Dating (20分)的主要内容,如果未能解决你的问题,请参考以下文章

1061 Dating (20分)

1061 Dating (20)

1061 Dating (20 分)难度: 一般 / 知识点: 模拟

PAT1061:Dating

1061. Dating (20)

PAT (Advanced Level) 1061. Dating (20)