代码如下:
//字符串模拟
#include<iostream>
#include<string>
#include<map>
#include<stdio.h>
#include<string.h>
using namespace std;
string first[12]={"tam","hel","maa","huh","tou","kes","hei","elo","syy","lok","mer","jou"};
string second[12]={ "jan","feb","mar","apr","may","jun","jly","aug","sep","oct","nov","dec"};
map<string,int> mp1;
map<string,int> mp2;
string s;
int n;
int to_num(string s){
int ans=0;
for(int i=0;i<s.length();i++){
ans=ans*10+s[i]-'0';
}
return ans;
}
int main(){
for(int i=0;i<12;i++){
mp1[first[i]]=i+1;
mp2[second[i]]=i+1;
}
cin>>n;
getchar();
for(int i=0;i<n;i++){
getline(cin,s);
if(s[0]>='0'&&s[0]<='9'){
int num=to_num(s);
int fir=num/13;
int sec=num-fir*13;
if(fir!=0&&sec!=0){
cout<<first[fir-1]<<" "<<second[sec-1];
}else if(fir==0&&sec!=0){
cout<<second[sec-1];
}else if(sec==0&&fir!=0){
cout<<first[fir-1];
}else{
cout<<"tret";
}
if(i!=n-1){
cout<<endl;
}
}else{
if(s.length()>3){
string s1="";
for(int j=0;j<3;j++){
s1=s1+s[j];
}
string s2="";
if(s[3]!=' '){
for(int j=5;j<8;j++){
s2=s2+s[j];
}
}else{
for(int j=4;j<7;j++){
s2=s2+s[j];
}
}
int fir=0,sec=0;
if(s1!="tret"){
fir=mp1[s1];
}
if(s2!="tret"){
sec=mp2[s2];
}
cout<<fir*13+sec;
if(i!=n-1){
cout<<endl;
}
}else{
string s1="";
for(int j=0;j<3;j++){
s1=s1+s[j];
}
if(mp1[s1]!=0){
cout<<mp1[s1]*13;
}
if(mp2[s1]!=0){
cout<<mp2[s1];
}
if(i!=n-1){
cout<<endl;
}
}
}
}
return 0;
}