1014 福尔摩斯的约会 (20分)+测试点解析(思路详解)+测试样例

26 篇文章 0 订阅

题目链接
思路
注意:
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;
}

  • 4
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值