pat1061. Dating (20)

Source: Internet
Author: User

1061. Dating (20) time limit MS Memory limit 65536 KB code length limit 16000 B award Program StandardAuthor Chen, Yue

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 is actually referring to the coded time "Thursday 14:0 4 "--since the first common capital 中文版 (case sensitive) shared by the first and strings is the 4th capital Le Tter ' 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 + a D Ay is represented by the numbers from 0 to 9 and the capital letters from A to N, respectively); and the Chinese letter gkfx by the last of the strings is ' s ' at the 4th position, representing the 4th minute. Now given and pairs of strings, you is supposed to help Sherlock decode the dating time.

Input Specification:

Each input file contains the one test case. Each case gives 4 non-empty strings of no more than, characters without white space in 4 lines.

Output Specification:

For each test case, print the decoded time on one line, in the format ' Day hh:mm ', where ' Day ' is a 3-character abbreviati On for the days in a week--that's, ' 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, the result is a unique for each case.

Sample Input:
3485djdkxh4hhge 2984AKDFKKKKGGEDSB S&HGSFDK d&hyscvnm
Sample Output:
THU 14:04

Submit Code

Problems. Test instructions unclear, and did not indicate that the two string characters correspond to the meaning of equality is the character size and character in the position of the string itself is also equal, so for the best problem, purely to do the problem!

Here's what I think is the right code:

1#include <stdio.h>2#include <stdlib.h>3#include <string.h>4#include <iostream>5 using namespacestd;6 7 Const intn= the;8 Charw[7][4]={{"MON"},{"TUE"},{"WED"},{"THU"},{"FRI"},{"SAT"},{"SUN"}};9 intMain ()Ten { One     CharS1[n],s2[n],s3[n],s4[n]; Ascanf"%s%s%s%s", S1,S2,S3,S4); -     intI=0; -     intweek,hh,mm; the      while(I<strlen (S1) &&i<strlen (S2)) { -         if(s1[i]==s2[i]&&s1[i]>='A'&&s1[i]<='G'){ -week=s1[i]-'A'; -              Break; +         } -i++; +     } Ai++; at      while(I<strlen (S1) &&i<strlen (S2)) { -         if(s1[i]==s2[i]&& (s1[i]>='A'&&s1[i]<='N')|| (s1[i]>='0'&&s1[i]<='9'))){ -             if((s1[i]>='A'&&s1[i]<='N')) -hh=s1[i]-'A'+Ten; -             Else if(s1[i]>='0'&&s1[i]<='9') -hh=s1[i]-'0'; in              Break; -         } toi++; +     } -I=0; the      while(I<strlen (S3) &&i<strlen (S4)) { *         if(s3[i]==s4[i]&& (s3[i]>='A'&&s3[i]<='Z')|| (s3[i]>='a'&&s3[i]<='Z'))){ $mm=i;Panax Notoginseng              Break; -         } thei++; +     } Aprintf"%s%02d:%02d\n", w[week],hh,mm); the     return 0; +}

pat1061. Dating (20)

Related Article

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.