分析:【第一对相同的大写英文字母,包括A-G】,【第二对相同的字符,包括0-9,A-N】,【第三对相同的英文字母,包括大小写】,只要不踩坑,题目还是挺容易的......
PS:限定字符的范围时,千万千万不要忘记写等号!!!比如ch<='a',不要写出ch<'a'!!!
#include <iostream>
#include <cstdio>
using namespace std;
string week[8] = {"MON", "TUE", "WED", "THU", "FRI", "SAT","SUN"};
int main()
{
string str[4];
int len[4];
for(int i=0; i<4; i++){
cin>>str[i];
len[i] = str[i].length();
}
int limit1 = len[0]<=len[1]?len[0]:len[1];
int limit2 = len[2]<=len[3]?len[2]:len[3];
int time=1;
for(int i=0; i<limit1; i++){
if(time == 1 && str[0][i] == str[1][i]){
if(str[0][i] >= 'A' && str[0][i] <= 'G'){
cout<<week[(str[0][i]-'A')]<<" ";
time++;
}
} else if(time == 2 && str[0][i] == str[1][i]){
if(str[0][i] >= '0' && str[0][i] <= '9'){
cout<<'0'<<(str[0][i] - '0')<<":";
break;
} else if(str[0][i] >= 'A' && str[0][i] <= 'N'){
cout<<(str[0][i] - 'A' + 10)<<":";
break;
}
}
}
for(int i=0; i<limit2; i++){
if(str[2][i] == str[3][i]&&((str[2][i]>='a'&&str[2][i]<='z')||(str[2][i]>='A'&&str[2][i]<='Z'))){
printf("%02d\n", i);
break;
}
}
return 0;
}