AcWing 1547. 约个会 --- 不容易
原题链接
简单
作者:
Value
,
2020-07-13 20:23:42
,
所有人可见
,
阅读 589
#include <iostream>
#include <cstdio>
using namespace std;
string s[4];
char today[8][10] = {"", "MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN"};
bool isfit(char t){
if((t >= '0' && t <= '9') || (t >= 'A' && t <= 'N')) return true;
return false;
}
int main(){
for(int i = 0; i < 4; i ++ ) cin >> s[i];
int day, hour, minute;
bool flag = false;
for(int i = 0; i < s[0].size() && i < s[1].size(); i ++ ){
if(flag && s[0][i] == s[1][i] && isfit(s[0][i])){
if(s[0][i] >= '0' && s[0][i] <= '9') hour = s[0][i] - '0';
else hour = s[0][i] - 'A' + 10;
break;
}
if(!flag && s[0][i] == s[1][i] && s[0][i] >= 'A' && s[0][i] <= 'Z' && s[0][i] - 'A' + 1 <= 7){
day = s[0][i] - 'A' + 1;
flag = true;
}
}
for(int i = 0; i < s[2].size() && i < s[3].size(); i ++ ){
if(s[2][i] == s[3][i] && ((s[2][i] >= 'A' && s[2][i] <= 'Z') || (s[2][i] >= 'a' && s[2][i] <= 'z'))){
minute = i;
break;
}
}
printf("%s %02d:%02d\n", today[day], hour, minute);
return 0;
}