1061 Dating (20 分)
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
思路分析
此题属于无聊题
在看懂题目的情况下,只要掌握最基本的C语言如何输入与输出字符串即可
#include<cstdio>
#include<iostream>
#include<cstring>
#define MAX 70
char arr1[MAX];
char arr2[MAX];
char arr3[MAX];
char arr4[MAX];
int main()
{
scanf("%s %s %s %s",arr1,arr2,arr3,arr4);
int dateNum=0;
for(int i=0;i<strlen(arr1)||i<strlen(arr2);i++)
{
if( (arr1[i]==arr2[i]) && (arr1[i]>='A'&&arr1[i]<='G')
&& (arr2[i]>='A'&&arr2[i]<='G') )
{
dateNum = i;
break;
}
}
char hour;
for(int i=dateNum+1;i<strlen(arr1)||i<strlen(arr2);i++)
{
if( (arr1[i]==arr2[i]) && (arr1[i]>='A'&&arr1[i]<='N')
&& (arr2[i]>='A'&&arr2[i]<='N') ||
(arr1[i]==arr2[i]) && (arr1[i]>='0'&&arr1[i]<='9')
&& (arr2[i]>='0'&&arr2[i]<='9')
)
{
hour = arr1[i];
break;
}
}
int minute=0;
for(int i=0;i<strlen(arr3)||i<strlen(arr4);i++)
{
if
(
(arr3[i]==arr4[i])&& (arr3[i]>='A'&&arr3[i]<='Z') && (arr4[i]>='A'&&arr4[i]<='Z')
|| (arr3[i]==arr4[i])&& (arr3[i]>='a'&&arr3[i]<='z') && (arr4[i]>='a'&&arr4[i]<='z')
)
{
minute = i;
break;
}
}
//printf("%d %c",dateNum,hour);
//output part
if(arr1[dateNum]=='A')printf("MON ");
if(arr1[dateNum]=='B')printf("TUE ");
if(arr1[dateNum]=='C')printf("WED ");
if(arr1[dateNum]=='D')printf("THU ");
if(arr1[dateNum]=='E')printf("FRI ");
if(arr1[dateNum]=='F')printf("SAT ");
if(arr1[dateNum]=='G')printf("SUN ");
if(hour=='0')printf("00:");
if(hour=='1')printf("01:");
if(hour=='2')printf("02:");
if(hour=='3')printf("03:");
if(hour=='4')printf("04:");
if(hour=='5')printf("05:");
if(hour=='6')printf("06:");
if(hour=='7')printf("07:");
if(hour=='8')printf("08:");
if(hour=='9')printf("09:");
if(hour=='A')printf("10:");
if(hour=='B')printf("11:");
if(hour=='C')printf("12:");
if(hour=='D')printf("13:");
if(hour=='E')printf("14:");
if(hour=='F')printf("15:");
if(hour=='G')printf("16:");
if(hour=='H')printf("17:");
if(hour=='I')printf("18:");
if(hour=='J')printf("19:");
if(hour=='K')printf("20:");
if(hour=='L')printf("21:");
if(hour=='M')printf("22:");
if(hour=='N')printf("23:");
if(minute<=9)
printf("0%d",minute);
else printf("%d",minute);
}