本文主要是介绍1061. Dating 解析,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
一开始把题目想复杂了。以为要匹配字符一样的比较。结果发现直接按顺序相同位置进行比较就好了。。。
#include <iostream>
#include <algorithm>
#include <cstring>
#include <climits>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <set>using namespace std;char day[7][4] ={"MON","TUE","WED","THU","FRI","SAT","SUN"};
string s1,s2,s3,s4;
bool isVis[256];
int d,h,m;int main(){cin >> s1 >> s2 >> s3 >> s4;bool tag = false;int posi = 0 ,posj = 0;for(int i = 0; i < s1.size() && i < s2.size() && !tag ;i++){if(s1[i] >= 'A' && s1[i] <= 'G'){if(s1[i] == s2[i]){d = s1[i] - 'A';posi = i;tag = true;}}}tag =false;for(int i = ++posi; i < s1.size() && i < s2.size() && !tag ;i++){if((s1[i] >= 'A' && s1[i] <= 'N')|| (s1[i] >= '0' && s1[i] <= '9')){if(s1[i] == s2[i]){for(int j = ++posj ;j < s2.size() && !tag ;j++){if(s2[j] == s1[i]){if(s1[i] >= 'A' && s1[i] <= 'N'){h = s1[i] - 'A' + 10;}elseh = s1[i]-'0';tag = true;}}}}}for(int i = 0 ;i < s3.size() && i < s4.size();i++){if((s3[i] >= 'A' && s3[i] <= 'Z') || (s3[i] >= 'a' && s3[i] <= 'z')){if(s3[i] == s4[i]){m = i;break;}}}printf("%s %02d:%02d\n",&day[d],h,m);return 0;
}
这篇关于1061. Dating 解析的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!