题目链接
思路
注意:
1、一周只有7天且仅考虑大写字母,故范围为A~G
2、0 ~ 23用0~ 9和A ~N表示
3、找完前两个后记得跳出循环不再向后查找
4、从下标0开始数且仅考虑字母相同
5、注意输出格式(例 : 是英文字符,不足2位的要补成2位)
附赠两个测试例子
测试一
3485djDkxh4hhG0
2984akDfkkkkgg0dsb
s&hgfdkiggggs
d&Hycvnmzzzzs
输出
THU 00:12
测试二:
HcCO2eA
HcCO2eB
cCaseC
cCaseD
输出
WED 02:00
AC代码
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<string>
#include<map>
#include<stack>
using namespace std;
typedef long long ll;
const int maxn=1e6;
int main()
{
string str1;
string str2;
string str3;
string str4;
cin>>str1>>str2>>str3>>str4;
int len1=str1.length();
int len2=str2.length();
int len3=str3.length();
int len4=str4.length();
int m=min(len1,len2);
int n=0;
for(int i=0;i<m;i++)
{
if(n==2)
break;
if(str1[i]==str2[i])
{
if(n==0&&str1[i]>='A'&&str1[i]<='G')//一周只有7天
{
int num=str1[i]-'A';
if(num==0)
{
cout<<"MON ";
}else if(num==1)
{
cout<<"TUE ";
}else if(num==2)
{
cout<<"WED ";
}else if(num==3)
{
cout<<"THU ";
}else if(num==4)
{
cout<<"FRI ";
}else if(num==5)
{
cout<<"SAT ";
}else if(num==6)
{
cout<<"SUN ";
}
n++;
}else if(n==1)
{
if(str1[i]>='0'&&str1[i]<='9')
{
cout<<"0"<<str1[i]<<":";
n++;
}
else if(str1[i]>='A'&&str1[i]<='N')
{
int num=10+str1[i]-'A';
cout<<num<<":";
n++;
}
}
}
}
m=min(len3,len4);
n=0;
for(int i=0;i<m;i++)
{
if(str3[i]==str4[i]&&((str3[i]>='a'&&str3[i]<='z')||(str3[i]>='A'&&str3[i]<='Z')))
{
n=i;
break;
}
}
if(n<10)
cout<<"0"<<n<<endl;
else
cout<<n<<endl;
return 0;
}