PAT B Zhenti 1004- Holmes dating

Title Description

Sherlock Holmes received a strange note: "we meet it 3485djDkxh4hhGE 2984akDfkkkkggEdsb s & hgsfdk d & Hyscvnm!". Detective soon realized that the note strange gibberish is actually dating the time "14:04 Thursday", because in front of the first two strings for the same capital letters (case sensitive distinction) is the first 4 the letter 'D', the representative Thursday; the same character a second pair is 'E', it is the first five letters of the alphabet, the representative day of 14 hours (so one is 0:00 to 23:00 by the numbers 0 to 9, and the capital letters a represents N); behind the first two for the same string of letters 's' appears in the fourth position (counting from 0), the representative of the first 4 minutes. Now given two pairs of strings, please help Holmes decoded appointment time.

Enter a description:

4 are given in the input line 4 non-empty, without a space, and the length of the string 60 is not exceeded.

Output Description:

Output in a row dating time, in the format "DAY HH: MM", where the "DAY" is a 3-week-character abbreviation that MON = Monday, TUE for Tuesday, WED for Wednesday, THU day of the week
Si, FRI representation Friday, SAT for Saturday, SUN for Sunday. Enter the topic guarantee the existence of a unique solution for each test.

Input example:

3485djDkxh4hhGE
2984akDfkkkkggEdsb
s&hgsfdk
d&Hyscvnm

Output example:

THU 14:04

//1004
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
	string a1,a2,b1,b2;
	cin>>a1>>a2>>b1>>b2;
	int la1,la2,lb1,lb2;
	la1=a1.length();
	la2=a2.length();
	lb1=b1.length();
	lb2=b2.length();
	char ca1[la1];
	char ca2[la2];
	char cb1[lb1];
	char cb2[lb2];
	strcpy(ca1,a1.c_str());
	strcpy(ca2,a2.c_str());
	strcpy(cb1,b1.c_str());
	strcpy(cb2,b2.c_str());
	
	int i=0,count1=0,count2=0,s=0,m=0,k=0;
	//记录第一组数据得到的信息 
	char time[3]; 
	for(i=0;i<la1&&i<la2;i++)
	{
		if((ca1[i]>'A'||ca1[i]=='A')&&(ca1[i]<'Z'||ca1[i]=='Z')&&ca1[i]==ca2[i])
		{
			//printf("a1中的字符为:%c  a2中相同的字符为:%c\n",ca1[i],ca2[i]);
			count1++;
			if(count1==1)
			{
				time[0]=ca1[i]; 
				m=i;
				break;
			}
		}	
	}
	m=m+1;
	for(k=m;k<la1&&k<la2;k++)
	{
		if(ca1[k]==ca2[k])
		{
			if((ca1[k]>'0'||ca1[k]=='0')&&(ca1[k]<'9'||ca1[k]=='9'))
			{
				time[1]=ca1[k];
				break;
			}
			if((ca1[k]>'A'||ca1[k]=='A')&&(ca1[k]<'Z'||ca1[k]=='Z'))
			{
				time[1]=ca1[k];
				break;
			}
		}
	}
	//第二组字符串的信息
	for(i=0;i<lb1&&i<lb2;i++)
	{
		if((cb1[i]>'a'||cb1[i]=='a')&&(cb1[i]<'z'||cb1[i]=='z')&&cb1[i]==cb2[i])
		{
			s=i;
			break; 
		}
		if((cb1[i]>'A'||cb1[i]=='A')&&(cb1[i]<'Z'||cb1[i]=='Z')&&cb1[i]==cb2[i])
		{
			s=i;
			break; 
		}
	}

	if(time[0]=='A')
	{
		cout<<"MON ";
	}
	if(time[0]=='B')
	{
		cout<<"TUE ";
	}
	if(time[0]=='C')
	{
		cout<<"WED ";
	}
	if(time[0]=='D')
	{
		cout<<"THU ";
	}
	if(time[0]=='E')
	{
		cout<<"FRI ";
	}
	if(time[0]=='F')
	{
		cout<<"SAT ";
	}
	if(time[0]=='G')
	{
		cout<<"SUN ";
	}
	//小时
	if(time[1]=='A')
	{
		cout<<"10";
	}
	if(time[1]=='B')
	{
		cout<<"11";
	}
	if(time[1]=='C')
	{
		cout<<"12";
	}
	if(time[1]=='D')
	{
		cout<<"13";
	}
	if(time[1]=='E')
	{
		cout<<"14";
	}
	if(time[1]=='F')
	{
		cout<<"15";
	}
	if(time[1]=='G')
	{
		cout<<"16";
	}if(time[1]=='H')
	{
		cout<<"17";
	}if(time[1]=='I')
	{
		cout<<"18";
	}if(time[1]=='J')
	{
		cout<<"19";
	}if(time[1]=='K')
	{
		cout<<"20";
	}if(time[1]=='L')
	{
		cout<<"21";
	}if(time[1]=='M')
	{
		cout<<"22";
	}if(time[1]=='N')
	{
		cout<<"23";
	}
	if((time[1]>'0'||time[1]=='0')&&(time[1]<'9'||time[1]=='9'))
	{
		cout<<"0"<<time[1];
	}
	//分钟 
	if(s<10)
	{
		cout<<":0"<<s<<endl; 
	}
	else
	{
		cout<<":"<<s<<endl; 
	}
	
	return 0;
}
Released seven original articles · won praise 2 · views 90

Guess you like

Origin blog.csdn.net/qq_41865468/article/details/104060750