题目描述
知识点: 进制转化
思路: 没啥好说的,有点小麻烦。细心点即可。
#include<iostream>
#include<unordered_map>
using namespace std;
string small12[13] = {"","jan", "feb", "mar", "apr", "may", "jun", "jly", "aug", "sep", "oct", "nov", "dec"};
string more12[13] = {"","tam", "hel", "maa", "huh", "tou", "kes", "hei", "elo", "syy", "lok", "mer", "jou"};
unordered_map<string,int> small_to_n,more_to_n;
int main(){
int n;
cin>>n;
for(int i = 1;i < 13;i++){
small_to_n[small12[i]] = i;
more_to_n[more12[i]] = i;
}
getchar();
while(n--){
string op;
getline(cin,op);
if(op == "tret" || op == "0"){
if(op == "tret")
cout<<"0"<<endl;
else cout<<"tret"<<endl;
continue;
}
if(op.length() > 3){//说明火星文
string op1 = op.substr(0,3);
string op2 = op.substr(4);
int x = more_to_n[op1]*13+small_to_n[op2];
cout<<x<<endl;
}else if(op[0] > '9' || op[0] < 0){
if(more_to_n[op] != 0){
int x = more_to_n[op] * 13;
cout<<x<<endl;
}else{
cout<<small_to_n[op]<<endl;
}
}else{
int x = stoi(op);
int x1 = x/13;
int y = x % 13;
if(x1 != 0)
cout<<more12[x1];
if(x1 != 0 && y != 0) cout<<" ";
if(y != 0) cout<<small12[y];
cout<<endl;
}
}
return 0;
}