不说废话先上代码中文链接
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
string s1,s2,s3,s4;
string arr[]={"MON","TUE","WED","THU","FRI","SAT","SUN"};
bool testA(char a){
if(a>='A'&&a<='G')return 1;
return 0;
}
bool testB(char a){
if(a>='A'&&a<='N')return 1;
if(a>='0'&&a<='9')return 1;
return 0;
}
bool testC(char a){
if(a<='z'&&a>='a'||a<='Z'&&a>='A')return 1;
else return 0;
}
vector<int>ans;
int main(){
cin>>s1>>s2>>s3>>s4;
int i=0;
for(;i<s1.size()&&i<s2.size();i++){
if(testA(s1[i])&&s1[i]==s2[i]){
ans.push_back(s1[i]-'A');
break;
}
}
i++;
for(;i<s1.size()&&i<s2.size();i++){
if(testB(s1[i])&&s1[i]==s2[i]){
if(s1[i]>='0'&&s1[i]<='9')ans.push_back(s1[i]-'0');
else ans.push_back(s1[i]-'A'+10);
break;
}
}
for(int i=0;i<s3.size()&&i<s4.size();i++){
if(testC(s3[i])&&s3[i]==s4[i])ans.push_back(i);
}
cout<<arr[ans[0]]<<" ";
printf("%02d:%02d",ans[1],ans[2]);
}
解题思路
看不懂题目的可以看最上面的中文链接
简单的字符串比较