PAT (Advanced Level) 1061. Dating (20)

Posted Fighting Heart

tags:

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

简单模拟。

#include<stdio.h>
#include<string.h>

char s1[70],s2[70],s3[70],s4[70];
char f[7][5]={"MON ", "TUE ","WED ","THU ","FRI ","SAT ","SUN "};
int a,b,c,flag;

int main()
{
    scanf("%s%s%s%s",s1,s2,s3,s4); flag=0;
    for(int i=0;s1[i]&&s2[i];i++) {
        if(s1[i]!=s2[i]) continue;
        if(flag==0) {if(s1[i]>=A&&s1[i]<=G) a=s1[i]-A+1,flag=1;}
        else if(flag==1){
            if(s1[i]>=0&&s2[i]<=9) b=s1[i]-0,flag=2;
            else if(s1[i]>=A&&s2[i]<=N) b=s1[i]-A+10,flag=2;
        }
    }
    for(int i=0;s3[i]&&s4[i];i++){
        if(s3[i]==s4[i]&&(s3[i]>=a&&s3[i]<=z)||(s3[i]>=A&&s3[i]<=Z)) {
            c=i;break;
        }
    }
    printf("%s%02d:%02d\n",f[a-1],b,c);
    return 0;
}

 

以上是关于PAT (Advanced Level) 1061. Dating (20)的主要内容,如果未能解决你的问题,请参考以下文章

PAT Advanced Level 1044

PAT Advanced Level 1043

PAT Advanced Level 1079

PAT Advanced Level 1095

PAT Advanced Level 1038

pat advanced level 1063