"Topic link"
Sherlock Holmes received a strange note: "Let's date!" 3485djdkxh4hhge 2984AKDFKKKKGGEDSB s&hgsfdk d&hyscvnm ". The big detective soon understood, the note on the strange garbled is actually the date of the time "Thursday 14:04", because the first two strings in the same uppercase English letter (case sensitivity) is the 4th letter ' D ', for Thursday, 2nd to the same character is ' E ', that is the 5th of the English alphabet, Represents the 14 head of the day (so that the day's 0 to 23 points are represented by the numbers 0 through 9, and the uppercase A through n); the next two string 1th to the same English letter ' s ' appears in the 4th position (counting from 0), representing the first 4 minutes. Now given two pairs of strings, please help Sherlock Holmes decode the time to get the appointment.
Input format:
The input gives 4 non-empty, space-free, and 60-length strings in 4 rows.
Output format:
The time to output an appointment in a single row, in the form "Day hh:mm", where "days" is a 3-character abbreviation for 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. The topic input guarantees that each test has a unique solution.
Input Sample:
3485djdkxh4hhge 2984AKDFKKKKGGEDSB S&HGSFDK d&hyscvnm
Sample output:
THU 14:04
Submit Code:
1#include <stdio.h>2#include <string.h>3 4 intMainvoid)5 {6 Char*week_table[] = {"MON","TUE","WED","THU","FRI","SAT","SUN"};7 Charstr1[ A], str2[ A], str3[ A], str4[ A];8 inti;9 intWeek, hour, second;Ten intlen1, Len2, Len3, Len4; One Ascanf"%s%s%s%s", str1, str2, STR3, STR4); - -Len1 =strlen (str1); theLen2 =strlen (str2); -Len3 =strlen (STR3); -Len4 =strlen (STR4); - +Week = Hour = Second =0; - //Note the topic of the word game + //The 1th pair is the same uppercase English letter, where the letter is represented in the alphabet week A for(i =0; I < len1 && I < len2; i++) at { - if(Str1[i] = = Str2[i] && (Str1[i] >='A'&& Str1[i] <='G')) - { -Week = Str1[i]-'A'; - Break; - } in } - //The 2nd pair of the same character, (0~9,a~n) represents hour to for(i++; i < len1 && i < len2; i++) + { - if(Str1[i] = = Str2[i] && ((Str1[i] >='A'&& Str1[i] <='N') || (Str1[i] >='0'&& Str1[i] <='9'))) the { * if(Str1[i] >='A'&& Str1[i] <='N') $hour = Str1[i]-'A'+Ten;Panax Notoginseng Else -hour = Str1[i]-'0'; the + Break; A } the } + - //1th to the same English letter, where the letter is represented in the string second $ for(i =0; I < Len3 && I < len4; i++) $ { - if((str3[i] = = Str4[i]) && ((Str3[i] >='a'&& Str3[i] <='Z') || (Str3[i] >='A'&& Str3[i] <='Z'))) - { theSecond =i; - Break;Wuyi } the } - Wuprintf"%s%02d:%02d", Week_table[week], hour, second); - About return 0; $}
This topic is a pit father of the word game ah, embarrassed ...
PAT (Basic level) practise:1014. Sherlock Holmes's date