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.

上一篇:拉伯简讯创业板指年涨65% 茅台逼近2000


下一篇:C++第九课:逐步深入[独自思考]