#include <iostream>
#include <string>
using namespace std;
string a[13]={"tret","jan","feb","mar","apr","may","jun","jly","aug","sep","oct","nov","dec"};
string b[13]={"###","tam","hel","maa","huh","tou","kes","hei","elo","syy","lok","mer","jou"};
string s;//可以在fun2中调用,因为函数不可以传递string(可以用指针)
int len;//直接在fun2中调用
void fun1(int e){
if(e/13) cout<<b[e/13]<<" ";
cout<<a[e%13];
}
void fun2(){
int t1=0,t2=0;
string s1=s.substr(0,3);
string s2;
if(len>4) s2=s.substr(4,3);
for(int j=1;j<13;j++){
if(s1==a[j]||s2==a[j]) t2=j;
if(s1==b[j]) t1=j;
}
cout<<t1*13+t2;
}
int main(){
int n;
cin>>n;
getchar();
for(int i=0;i<n;i++){
getline(cin,s);//此处是getline而不是cin
len=s.length();
if(s[0]<='9'&&s[0]>='0')
fun1(stoi(s));
else
fun2();
cout<<endl;
}
return 0;
}
有的测试通不过,应该是fun1的问题
参考liuchuo添加链接描述