Algorithmic question: Sherlock Holmes's date

Source: Internet
Author: User

Topic Description Narration

Sherlock Holmes received a strange note: "Let's date!"

3485djdkxh4hhge 2984AKDFKKKKGGEDSB s&hgsfdk d&hyscvnm ". Big Detective Very

Be clear soon. The strange garbled characters on the note are actually the time of the date "Thursday 14:04". Because the first two strings in the 1th pair are the same uppercase English letters (uppercase and lowercase are distinguished) are

The 4th letter ' D ', representing Thursday; the 2nd pair of the same character is ' E '. That is the 5th English letter, which represents the first 14 of the day (so the day's 0 to 23 points from the number 0 to 9,

and capital letters A through n), followed by two strings 1th to the same English letter ' s ' out of the 4th position (counting from 0). Represents the first 4 minutes.

Now given two pairs of strings,

Please help Holmes decode the time to get the appointment.

Input descriptive narrative:

The input gives 4 non-empty, space-less, and 60-length strings in 4 rows.

Output Descriptive narrative:

The time to output an appointment in a row, in the form of "Day hh:mm", where "Day" is the 3-character abbreviation for a week, that is, Mon, which represents Monday. Tue said Tuesday. Wed said Wednesday, Thu said the week

Four. Fri said Friday, Sat said Saturday, Sun said Sunday. The topic input guarantees that each test has a unique solution.

Input Sample:

3485djdkxh4hhge

2984akDfkkkkggEdsb

S&hgsfdk

D&hyscvnm

Sample output:

THU 14:04

#include <iostream>using namespace STD;intMain () {Const Charweek[][4] = {"MON","TUE","WED","THU","FRI","SAT","SUN"};Charinputstr1[ -];Charinputstr2[ -];Charinputstr3[ -];Charinputstr4[ -];Cin>> inputStr1;Cin>> inputStr2;Cin>> INPUTSTR3;Cin>> INPUTSTR4;Char*P1 = INPUTSTR1;Char*P2 = INPUTSTR2;intj =0;Charsach[2];intK =0; while(k! =2)    {if(k = =1&& *p1==*p2) {sach[k++] = *P1; }if(k==0&& *p1>' 9 '&& *P1 = = *p2) {sach[k++] = *P1;        } p1++;    p2++; }intCount =0;    P1 = InputStr3; P2 = INPUTSTR4; while(1)    {if(Isalpha(*P1) && *p1 = = *p2) { Break;        } count++;        p1++;    p2++; }inti =0; while("ABCDEFG"[i]! = sach[0]) i++;cout<< week[i]<<" "; while("0123456789ABCDEFGHIJKLMNO"[j]! = sach[1]) J + +;if(J <Ten)        {cout<<"0"<< J <<":"; }Else{cout<< J <<":"; }if(Count <Ten)cout<<"0"<< Count << Endl;Else cout<< Count << Endl;return 0;}

Algorithmic question: Sherlock Holmes's date

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.