我感觉是这题出的有问题,第二个只说了字母,并没有说第二个大写字母...为啥就得从第一个大写字母后面开始检索呢。
#include <bits/stdc++.h>
using namespace std;
map<int,string> mp = {{1,"MON"},{2,"TUE"},{3,"WED"},{4,"THU"},{5,"FRI"},{6,"SAT"},{7,"SUN"}};
int main() {
int d,h,m;
string s1,s2,s3,s4;
cin>>s1>>s2>>s3>>s4;
int len = min(s1.size(),s2.size());
int count = 0;
for(int i=0;i<len;i++){
if(count==0 && s1[i]==s2[i] && s1[i]>='A' && s1[i]<='G'){
count++;
d=s1[i]-'A'+1;
continue;
}
if(count==1 && s1[i]==s2[i] && s1[i] >='0' && s1[i]<='9'){
h=s1[i]-'0';
break;
}
if(count==1 && s1[i]==s2[i] && s1[i]>='A' && s1[i]<='N'){
h=s1[i]-'A'+10;
break;
}
}
//后面两个
len = min(s3.size(),s4.size());
for(int i=0; i<len; i++) {
if(s3[i]==s4[i] && isalpha(s3[i]) && isalpha(s4[i])) {
m=i;
break;
}
}
printf("%s %02d:%02d",mp[d].c_str(),h,m);
return 0;
}
标签:int,s2,约会,福尔摩斯,&&,1014,s1,size
From: https://www.cnblogs.com/chengyiyuki/p/18134879