PAT1014. 福尔摩斯的约会

相同指位置也形同,囧,没观察到。#1:边界A-G。#2:边界0-9,A-N。#3,边界,isslpha

#include<iostream>
#include<cstdio>
#include<cctype>
#include<string>
using namespace std;

string st,ss;
char*day[7]={"MON","TUE","WED","THU","FRI","SAT","SUN"};
int isDay(int ch){return ch>='A'&&ch<='G';}
int isHour(int ch){return(ch>='0'&&ch<='9')||(ch>='A'&&ch<='N');}

int main(){
cin>>st>>ss;
int i=0;char ch;

while(!(isDay(st[i])&&isDay(ss[i])&&st[i]==ss[i])) ++i;
ch=st[i++];
printf("%s ",day[ch-'A']);

while(!(isHour(st[i])&&isHour(ss[i])&&st[i]==ss[i])) ++i;
ch=st[i];
printf("%02d:",((ch>='0'&&ch<='9')?(ch-'0'):(ch-'A'+10)));

cin>>st>>ss;i=0;
while(!(isalpha(st[i])&&isalpha(ss[i])&&st[i]==ss[i])) ++i;
printf("%02d",i);

return 0;}


你可能感兴趣的:(PAT1014. 福尔摩斯的约会)