其他分享
首页 > 其他分享> > 1014 福尔摩斯的约会 (20分)

1014 福尔摩斯的约会 (20分)

作者:互联网

#include <iostream>
#include <string.h>
#include <cmath>
using namespace std;

int main()
{
    char a[61],b[61],c[61],d[61];
    int w=0,w1=0,h=0,m;
    cin>>a>>b>>c>>d;
    char day[8][4]={"MON","TUE","WED","THU","FRI","SAT","SUN"};
    int l=strlen(a);
    if(strlen(b)<l)
        l=strlen(b);
    for(int i=0;i<l;i++)
    {
        if(a[i]==b[i])
        {
            if(a[i]>=65&&a[i]<=71&&w1==0)
            {
                w1=1;
                w=a[i]-65;
            }
            else if(a[i]>=65&&a[i]<=78&&w1==1)
            {
                h=a[i]-55;
                break;
            }
            else if(w1==1&&a[i]>=48&a[i]<=57)
            {
                h=a[i]-48;
                break;
            }
        }
    }
    l=strlen(c);
    if(strlen(d)<l)
        l=strlen(d);
    for(int i=0;i<l;i++)
    {
        if(c[i]==d[i]&&((c[i]>=65&&c[i]<=90)||(c[i]>=97&&c[i]<=122)))
        {
            m=i;
            break;
        }
    }
    cout<<day[w]<<" ";
    if(h<10)
        cout<<"0"<<h<<":";
    else
        cout<<h<<":";
    if(m<10)
        cout<<"0"<<m;
    else
        cout<<m;
    return 0;
}

注意输出格式如果不足10,要补0.

标签:20,int,福尔摩斯,char,61,65,&&,1014,include
来源: https://www.cnblogs.com/QRain/p/12227854.html