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 #include <iostream> 2 #include <cstdio> 3 using namespace std; 4 5 char str[4][80]; 6 char week[7][6]={ 7 8 "MON", 9 "TUE", 10 "WED", 11 "THU", 12 "FRI", 13 "SAT", 14 "SUN" 15 }; 16 int main(int argc, char *argv[]) 17 { 18 for(int i=0;i<4;i++) 19 { 20 scanf("%s",str[i]); 21 } 22 bool flag=false; 23 for(int i=0;str[0][i]!=‘\0‘&&str[1][i]!=‘\0‘;i++) 24 { 25 if(!flag&&str[0][i]==str[1][i]&&str[0][i]>=‘A‘&&str[0][i]<=‘G‘) 26 { 27 flag=true;; 28 int index=str[0][i]-‘A‘; 29 printf("%s ",week[index]); 30 } 31 else if(flag&&str[0][i]==str[1][i]) 32 { 33 if(str[0][i]>=‘0‘&&str[0][i]<=‘9‘) 34 { 35 printf("%02d:",str[0][i]-‘0‘); 36 break; 37 } 38 else if(str[0][i]>=‘A‘&&str[0][i]<=‘N‘) 39 { 40 printf("%02d:",str[0][i]-‘A‘+10); 41 break; 42 } 43 } 44 } 45 int ans; 46 for(int i=0;str[2][i]!=‘\0‘&&str[3][i]!=‘\0‘;i++) 47 { 48 if(str[2][i]==str[3][i]) 49 { 50 if(str[2][i]>=‘a‘&&str[2][i]<=‘z‘||str[2][i]>=‘A‘&&str[2][i]<=‘Z‘) 51 { 52 ans=i; 53 break; 54 } 55 } 56 } 57 printf("%02d\n",ans); 58 59 return 0; 60 }