solution
- 把日期转换为标准位数,不足则补零,判断是否为对称日期。
- 月日可能会缺一个0,年份可能缺0~3个零。
#include<iostream>
#include<string>
#include<map>
using namespace std;
int main(){
int n, flag;
map<string, string> mp;
string m, y, d, t[15] = {"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
for(int i = 1; i < 13; i++){
if(i < 10) mp[t[i]] = "0" + to_string(i);
else mp[t[i]] = to_string(i);
}
cin >> n;
while(n--){
flag = 1;
cin >> m >> d >> y;
if(d.size() < 3) d = "0" + d;
m = mp[m];
while(y.size() < 4) y = "0" + y;
if(y[0] != d[1] || y[1] != d[0] || y[2] != m[1] || y[3] != m[0]) flag = 0;
if(flag) cout << "Y " << y << m << d.substr(0, 2) << endl;
else cout << "N " << y << m << d.substr(0, 2) << endl;
}
return 0;
}