1044

//部分正确?
//

#include "stdafx.h"
#include
#include
#include
#include


using namespace std;

const vector low_mars = {"tret", "jan", "feb", "mar", "apr", "may", "jun", "jly", "aug", "sep", "oct", "nov", "dec" };
const vector high_mars = { "", "tam", "hel", "maa", "huh", "tou", "kes", "hei", "elo", "syy", "lok", "mer", "jou" };

unsigned mars_to_earth(string m, string n)
{
    unsigned ret=0;

    if (!m.empty() && find(high_mars.begin(), high_mars.end(), m)!=high_mars.end())
    {
        auto tmp = find(high_mars.begin(), high_mars.end(), m) - high_mars.begin();
        ret = ret + tmp * 13;
    }
    if (!n.empty() && find(low_mars.begin(), low_mars.end(), n)!=low_mars.end())
    {
        auto tmp = find(low_mars.begin(), low_mars.end(), n) - low_mars.begin();
        ret = ret + tmp;
    }
    return ret;
}

string earth_to_mars(unsigned k)
{
    unsigned high = k / 13;
    unsigned low = k % 13;

    string ret;

    if (high > 0)
    {
        ret = high_mars[high] + " ";
        if (low > 0)
        {
            ret = ret + low_mars[low];
        }
    }
    else
    {
        ret = ret + low_mars[low];
    }

    return ret;
}


int main()
{
    unsigned n;
    cin >> n;
    cin.ignore();

    string str;

    for (unsigned i = 0; i < n; ++i)
    {
        getline(cin, str);
        if (isalpha(str[0]))
        {
            string m, n;
            if (str.find(" ") != string::npos)
            {
                m = str.substr(0, str.find(" "));
                n = str.substr(str.find(" ") + 1, string::npos);
            }
            else
            {
                m = str;
                n = str;
            }
            cout << mars_to_earth(m, n);
        }
        else
        {
            unsigned k = stoul(str);
            cout << earth_to_mars(k);
        }
        if ((n - 1) != i)
        {
            cout << endl;
        }

    }

    system("pause");
    return 0;
}

你可能感兴趣的:(1044)