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 of the appointment is output in a row, in the format" 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 said Thursday, Fri said Friday, Sat said Saturday, Sun said Sunday. The topic input guarantees that each test has a unique solution.
#include <stdio.h> #include <stdlib.h> #include <string.h> #define N 60bool Islegal (char a); bool IsLegal1 (char a); bool IsLegal2 (char a); void day (int n); void Hour (char a); void Minute (int n); int main () {char First [N+1],second[n+1],third[n+1],forth[n+1]; Gets (first); Gets (second); Gets (third); Gets (forth); The day//////////////////////int Length1=strlen (first), Length2=strlen (second); int Length3 =strlen (third), Length4=strlen (forth); int i; for (i=0; i<length1 && i<length2;i++) {if (Islegal (First[i]) && Islegal (Second[i])//l Egal if ((First[i]-second[i]) ==0)//equal {day (first[i]-' A '); Break }}//the hour///////////////////////i++; for (; i<length1 && i<length2;i++) {if (IsLegal1 (First[i]) && IsLegal1 (Second[i])) if ((first[i)-second[i]) ==0)//equal {Hour (first[i]); Break }}//the minute for (i=0;i<length3 && i<length4;i++) {if (IsLegal2 (third[ I]) &&islegal2 (Forth[i]) if ((third[i]-forth[i)) ==0)//equal { Minute (i); Break }} system ("Pause"); return 0; }bool Islegal (char a) {if ((A-' a ') >=0 && (A-' G ') <=0) return true; else return false; }bool IsLegal1 (char a) {if ((A-' a ') >=0 && (A-' N ') <=0) | | ((A-' 0 ') >=0 && (A-' 9 ') <=0)) return true; else return false; }void Day (int n) {switch (n) {case 0:printf ("MON"); Case 1:printf ("TUE"); Case 2:printf ("WED"); Case 3:printf ("THU"); CaSe 4:printf ("FRI"); Case 5:printf ("SAT"); Case 6:printf ("SUN"); } return; }void Hour (char a) {int n=0; Switch (a) {case ' 0 ':p rintf ("XX:"); Case ' 1 ':p rintf ("N:"); Case ' 2 ':p rintf ("the"); Case ' 3 ':p rintf ("A:"); Case ' 4 ':p rintf (":"); Case ' 5 ':p rintf (":"); Case ' 6 ':p rintf (":"); Case ' 7 ':p rintf (":"); Case ' 8 ':p rintf (":"); Case ' 9 ':p rintf (":"); Case ' A ':p rintf ("Ten:"); Case ' B ':p rintf ("one:"); Case ' C ':p rintf ("N:"); Case ' D ':p rintf (":"); Case ' E ':p rintf ("+:"); Case ' F ':p rintf (":"); Case ' G ':p rintf ("+:"); Case ' H ':p rintf ("N:"); Case ' I ':p rintf (":"); Case ' J ':p rintf ("19:"); break; Case ' K ':p rintf ("A:"); Case ' L ':p rintf ("M:"); Case ' M ':p rintf ("N:"); Case ' N ':p rintf ("at:"); } return; }void Minute (int n) {printf ("%.2d\n", N); }bool IsLegal2 (char a) {if ((A-' a ') >=0 && (A-' Z ') <=0) | | ((A-' a ') >=0 && (A-' z ') <=0)) return true; else return false; }
1014. Sherlock Holmes's date