1100 Mars Numbers

题目描述
知识点: 进制转化
思路: 没啥好说的,有点小麻烦。细心点即可。

#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;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值