码迷,mamicode.com
首页 > 其他好文 > 详细

PAT (Advanced Level) 1061. Dating (20)

时间:2016-06-02 09:51:41      阅读:168      评论:0      收藏:0      [点我收藏+]

标签:

简单模拟。

#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)

标签:

原文地址:http://www.cnblogs.com/zufezzt/p/5551868.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!