AcWing 1547. 约会
原题链接
简单
#include <bits/stdc++.h>
using namespace std;
string week [7] = {"MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN"};
int main()
{
string Week, clock, minute1, minute2, res_week, res_clock, res_minute;
cin >> Week >> clock >> minute1 >> minute2;
// 先处理在周几
int idx;
for (size_t i = 0; i < Week.size() && i < clock.size(); i ++ )
{
if (Week[i] == clock[i] && (Week[i] >= 'A' && clock[i] <= 'G'))
{
res_week = week[Week[i] - 'A'];
idx = i + 1;
break;
}
}
// 然后处理几点
for (size_t i = idx; i < Week.size() && i < clock.size(); i ++ )
{
if (Week[i] == clock[i])
{
if (Week[i] >= '0' && Week[i] <= '9')
{
res_clock += '0';
res_clock += Week[i];
break;
}
else if (Week[i] >= 'A' && Week[i] <= 'N')
{
int k = Week[i] - 'A' + 10;
res_clock = to_string(k);
break;
}
}
}
// 处理几分
for (int i = 0; i <= 60; i ++ )
{
if (minute1[i] == minute2[i] && ((minute1[i] <= 'z' && minute1[i] >= 'a') || (minute1[i] >= 'A' && minute1[i] <= 'Z')))
{
if (i <= 9)
{
res_minute = '0' + to_string(i);
break;
}
else
{
res_minute = to_string(i);
break;
}
}
}
//输出
cout << res_week << ' ' << res_clock << ':' << res_minute;
return 0;
}