PAT甲级1061 Dating

时间:2023-03-10 03:02:59
PAT甲级1061 Dating

题目https://pintia.cn/problem-sets/994805342720868352/problems/994805411985604608

题意:

给定四个字符串。

前两个字符串中第一个相同的大写字母对应星期,第二个相同的数字或大写(A~N)表示小时。

后两个字符串中第一个相同的字母对应分钟。

这里的对应都是位置与位置一一对应。

思路:

按照题意简单模拟。要看清楚题目数据的要求。比如分钟要求的是English letter,数字相同是不算的。

 #include<cstdio>
#include<cstdlib>
#include<map>
#include<set>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<queue> #define inf 0x7fffffff
using namespace std;
typedef long long LL;
typedef pair<string, string> pr; string code[];
int len[];
string day[] = {"MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN"}; int main()
{
for(int i = ; i < ; i++){
cin>>code[i];
} char ch[];
int cnt = ;
for(int i = ; i < min(code[].length(), code[].length()); i++){
if(code[][i] == code[][i]){
if(cnt == && code[][i] >= 'A' && code[][i] <= 'G')
ch[cnt++] = code[][i];
else if(cnt == && (code[][i] >= 'A' && code[][i] <= 'N' || code[][i] >= '' && code[][i] <= ''))
ch[cnt++] = code[][i];
}
if(cnt == )break;
} //cout<<ch[0]<<ch[1]<<endl;
int pos;
for(int i = ; i < min(code[].length(), code[].length()); i++){
if(code[][i] == code[][i] && (code[][i] >= 'a' && code[][i] <= 'z' || code[][i] >= 'A' && code[][i] <= 'Z')){
pos = i;
break;
}
} int h;
if(ch[] >= 'A' && ch[] <= 'N'){
h = ch[] - 'A' + ;
}
else{
h = ch[] - '';
}
int d = ch[] - 'A';
cout<<day[d];
printf(" %02d:%02d\n", h, pos);
return ;
}