1061 Dating (20 分)难度: 一般 / 知识点: 模拟

Posted 辉小歌

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了1061 Dating (20 分)难度: 一般 / 知识点: 模拟相关的知识,希望对你有一定的参考价值。


https://pintia.cn/problem-sets/994805342720868352/problems/994805411985604608

#include<bits/stdc++.h>
using namespace std;
string s1,s2,s3,s4,ans;
string get(string s1,string s2,string s3,string s4)
{
    string ans;
    for(int i=0;i<s1.size();i++)
    {
        if(s1[i]==s2[i]&&ans.size()&&(s1[i]>='0'&&s1[i]<='9'||s1[i]>='A'&&s1[i]<='N')) 
        {
            ans+=s1[i];break;
        }
        if(s1[i]==s2[i]&&s1[i]>='A'&&s1[i]<='G')  ans+=s1[i];
    }
    for(int i=0;i<s3.size();i++) 
    {
        if(s3[i]==s4[i]&&(s3[i]>='A'&&s3[i]<='Z' || s3[i]>='a'&&s3[i]<='z' )) 
        {
            ans+=to_string(i);
            return ans;
        }
    }
}
int f(char c)
{
    if(c<='9') return c-'0';
    else return c-'A'+10;
}
string day[7] = {"MON","TUE","WED","THU","FRI","SAT","SUN"};
int main(void)
{
    cin>>s1>>s2>>s3>>s4;
    ans=get(s1,s2,s3,s4);
    printf("%s %02d:%02d",day[ans[0]-'A'].c_str(),f(ans[1]),stoi(ans.substr(2)));
    return 0;
}

以上是关于1061 Dating (20 分)难度: 一般 / 知识点: 模拟的主要内容,如果未能解决你的问题,请参考以下文章

1061 Dating (20分)

1061 Dating (20分)

1061 Dating (20)

1061. Dating (20)

PAT (Advanced Level) 1061. Dating (20)

PAT1061:Dating