其他分享
首页 > 其他分享> > 1061 Dating (20分)

1061 Dating (20分)

作者:互联网

1. 题目

2. 思路

难点在于理解题目的意思

3. 注意点

DAY的确定是必须大写字母,而且大写字母在A~G之间而不是全部大写字母
hh是数字或者大写字母,如果是大写字母必须在A~N之间,而且是在找完DAY之后往后继续寻找
MM是字母

4. 代码

#include<cstdio>
#include<algorithm>
#include<string>
#include<vector>

using namespace std;

string s1, s2, s3, s4; 

string week[7] = {"MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN"};

int main(){
    char cs1[61], cs2[61], cs3[61], cs4[61];
    scanf("%s %s %s %s", cs1, cs2, cs3, cs4);
    s1 = cs1;
    s2 = cs2;
    s3 = cs3;
    s4 = cs4;
    int i=0;
    int len = min(s1.length(), s2.length());
    char c1, c2;
    for(i=0;i<len;i++){
        if(s1[i] == s2[i] && s1[i] >= 'A' && s1[i] <= 'G'){
            c1 = s1[i];
            break;
        }
    }
    i++;
    for(;i<len;i++){
        if(s1[i] == s2[i] && (s1[i] >= 'A' && s1[i] <= 'N' || isdigit(s1[i]))){
            c2 = s1[i];
            break;
        }
    }
    len = min(s3.length(), s4.length());
    for(i=0;i<len;i++){
        if(s3[i] == s4[i] && isalpha(s3[i])){
            break;
        }
    }
    printf("%s ", week[c1-'A'].c_str());
    if(isalpha(c2)){
        printf("%d:", c2-'A'+10);
    }else{
        printf("%02d:", c2-'0');
    }
    printf("%02d", i);
}

标签:include,20,1061,s2,s1,大写字母,61,int,Dating
来源: https://www.cnblogs.com/d-i-p/p/12425748.html