写在前面
- 思路分析
- 按照题目所给方法找到相等字符后判断,输出时间不足2位数要在前面添0,即用%02d输出
- 10分钟a题
测试用例
input:
3485djDkxh4hhGE
2984akDfkkkkggEdsb
s&hgsfdk
d&Hyscvnm
output:
THU 14:04
ac代码
#include <iostream>
#include <cctype>
using namespace std;
int main()
{
string a, b, c, d;
cin >> a >> b >> c >> d;
char t[2];
int pos, i=0, j=0;
while(i < a.length() && i<b.length())
{
if(a[i]==b[i] && (a[i]>= 'A' && a[i]<='G'))
{
t[0] = a[i];
break;
}
i++;
}
i = i+1;
while(i<a.length() && i<b.length())
{
if(a[i]==b[i] && ((a[i]>= 'A' && a[i]<='N') || isdigit(a[i])))
{
t[1] = a[i];
break;
}
i++;
}
while(j<c.length() && j<d.length())
{
if(c[j]==d[j] && isalpha(c[j]))
{
pos = j;
break;
}
j++;
}
string week[7] = {"MON ", "TUE ", "WED ", "THU ", "FRI ", "SAT ", "SUN "};
int m = isdigit(t[1]) ? t[1]-'0' : t[1]-'A' + 10;
cout << week[t[0]-'A'];
printf("%02d:%02d", m, pos);
return 0;
}