//PAT1014
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
#include <vector>
#include <cstdio>
#include <cctype>
using namespace std;
inline bool is_week(char ch)
{
return (ch >= 'A' && ch <= 'G');
}
inline bool is_hour(char ch)
{
return ( ch>='0' && ch<='9') || ( ch>='A' && ch<='N' );
}
int main()
{
map<char, string> mp_week; //建立星期映射表
mp_week['A'] = "MON";
mp_week['B'] = "TUE";
mp_week['C'] = "WED";
mp_week['D'] = "THU";
mp_week['E'] = "FRI";
mp_week['F'] = "SAT";
mp_week['G'] = "SUN";
vector<string> v(4);
for (int i=0; i<4; i++)
{
cin>>v[i];
}
int i=0;
for (; i<v[0].length() && i<v[1].length(); i++)
{
if ( v[0][i] == v[1][i] && is_week( v[0][i] ) ) //相同位置相同字符且又是代表星期的字符
{
cout<<mp_week[v[0][i]]<<" ";
break;
}
}
for (i++; i<v[0].length() && i<v[1].length(); i++)
{
if ( v[0][i] == v[1][i] && is_hour( v[0][i] ) ) //相同位置相同字符且又是代表时间的字符
{
if ( v[0][i] <='9' )
cout<<"0"<<v[0][i]<<":"; //格式不能乱
else
cout<<static_cast<int>( v[0][i] - 'A' + 10 )<<":";
break;
}
}
for (i=0; i<v[2].length()&&i<v[3].length(); i++)
{
if ( v[2][i] == v[3][i] && isalpha(v[2][i]) ) //相同位置,相同字符且都是英文字符
break;
}
printf("%02d", i); //格式不能乱
return 0;
}
1014 福尔摩斯的约会 (20)
最新推荐文章于 2023-12-14 15:10:23 发布