代码:
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
int main(){
int n;
char low[13][5]={"tret","jan", "feb", "mar", "apr", "may",
"jun","jly", "aug", "sep", "oct", "nov", "dec"};
char high[13][5]={"tret","tam", "hel", "maa", "huh", "tou",
"kes", "hei", "elo", "syy", "lok", "mer", "jou"};
cin>>n;
cin.get();
while(n--){
int h=0,l=0,sum=0;
char a[20]={0};
cin.getline(a,10005);
if(a[0]>='0'&&a[0]<='9'){
sum=atoi(a);
l=sum%13;
h=sum/13;
if(sum<13)
printf("%s\n",low[sum]);
else if(sum>=13&&l==0){
printf("%s\n",high[h]);
}
else{
printf("%s %s\n",high[h],low[l]);
}
}
else{
int i,k=0,tag=0;
for(i=0;i<strlen(a);i++){
if(a[i]==' '){
tag=1;
break;
}
}
if(tag){
k=i+1;
for(int j=0;j<13;j++){
if(equal(a,a+i,high[j])){
h=j;
break;
}
}
}
int find=0;
for(int j=0;j<13;j++){
if(strcmp(a+k,low[j])==0){
l=j;
find=1;
break;
}
}
if(find==0){
for(int j=0;j<13;j++){
if(strcmp(a+k,high[j])==0){
h=j;
break;
}
}
}
printf("%d\n",h*13+l);
}
}
return 0;
}
// 1 2 3 4 5 6 7 8 9 10 11 12
// tam, hel, maa, huh, tou, kes, hei, elo, syy, lok, mer, jou
// jan, feb, mar, apr, may, jun, jly, aug, sep, oct, nov, dec
知识点: