1044 火星数字 (20 分)

#include<iostream>

#include<string>

#include<map>

using namespace std;

int main()

{

    string high[] = { "","tam","hel","maa","huh","tou","kes","hei","elo","syy","lok","mer","jou" };

    string low[] = {"","jan","feb","mar","apr","may","jun","jly","aug","sep","oct","nov","dec" };

    map<string, int>hxw;

    for (int i = 0; i <=12 ; i++)

        for (int j = 0; j <= 12; j++)

        {

            if(i==0)

                hxw[low[j]] = j;

            else if(j==0)

                hxw[high[i]] = i*13;

            else

             hxw[high[i] +" "+ low[j]] = j + i * 13;

        }

    hxw["tret"] = 0;

    map<string, int>::iterator it = hxw.begin();

    int cou;

    int num = 0;

    string numb="\0";

    cin >> cou;

    cin.get();

    for (int i = 0; i < cou; i++)

    {

        getline(cin,numb);

        if (numb[0] >= '0' && numb[0] <= '9')//输入的是数字

        {

            for (int j = 0;j<numb.size();j++)

            {

                num *= 10;

                num += numb[j] - '0';

            }

            if (num / 13 != 0 && num % 13 != 0)

                cout << high[num / 13] << " " << low[num % 13] << endl;

            else if (num == 0)

                cout << "tret" << endl;

            else if (num / 13 == 0)

                cout << low[num % 13] << endl;

            else

                cout << high[num/13] << endl;

        }

        else//输入的是火星文

        {

            //it=hxw.find(numb);

            cout<<hxw[numb]<<endl;

        }

        num = 0;

    }

    system("pause");

    return 0;

}

//C++之路

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值