码迷,mamicode.com
首页 > 其他好文 > 详细

1061 Dating (20分)

时间:2019-12-17 17:57:53      阅读:93      评论:0      收藏:0      [点我收藏+]

标签:pos   jdk   not   kkk   test   repr   ast   string   NPU   

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分)

标签:pos   jdk   not   kkk   test   repr   ast   string   NPU   

原文地址:https://www.cnblogs.com/57one/p/12055642.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!