1044.火星数字



#include<iostream>
#include<string>
#include<sstream>
using namespace std;

int toInt(string str) {
    int n;
    stringstream s;
    s << str;
    s >> n;
    return n;
}

void HX(string str) {
    int m = toInt(str);
    int g = m % 13;
    int s = m / 13;
    switch (s) {
        case 0:
            break;
        case 1:
            cout << "tam";
            break;
        case 2:
            cout << "hel";
            break;
        case 3:
            cout << "maa";
            break;
        case 4:
            cout << "huh";
            break;
        case 5:
            cout << "tou";
            break;
        case 6:
            cout << "kes";
            break;
        case 7:
            cout << "hei";
            break;
        case 8:
            cout << "elo";
            break;
        case 9:
            cout << "syy";
            break;
        case 10:
            cout << "lok";
            break;
        case 11:
            cout << "mer";
            break;
        case 12:
            cout << "jou";
            break;
    }
    switch(g) {
        case 0:
            if (s == 0) {
                cout << "tret";
            }
            break; 
        case 1:
            if (s != 0) {
                cout << ' ';
            }
            cout << "jan";
            break; 
        case 2:
            if (s != 0) {
                cout << ' ';
            }
            cout << "feb";
            break; 
        case 3:
            if (s != 0) {
                cout << ' ';
            }
            cout << "mar";
            break; 
        case 4:
            if (s != 0) {
                cout << ' ';
            }
            cout << "apr";
            break; 
        case 5:
            if (s != 0) {
                cout << ' ';
            }
            cout << "may";
            break; 
        case 6:
            if (s != 0) {
                cout << ' ';
            }
            cout << "jun";
            break; 
        case 7:
            if (s != 0) {
                cout << ' ';
            }
            cout << "jly";
            break; 
        case 8:
            if (s != 0) {
                cout << ' ';
            }
            cout << "aug";
            break; 
        case 9:
            if (s != 0) {
                cout << ' ';
            }
            cout << "sep";
            break; 
        case 10:
            if (s != 0) {
                cout << ' ';
            }
            cout << "oct";
            break; 
        case 11:
            if (s != 0) {
                cout << ' ';
            }
            cout << "nov";
            break; 
        case 12:
            if (s != 0) {
                cout << ' ';
            }
            cout << "dec";
            break; 
    }
    cout << endl;
}

int DQ(string str) {
    int n = 0;
    if (str == "tret") {
        n += 0;
    } else if (str == "jan") {
        n += 1;
    } else if (str == "feb") {
        n += 2;
    } else if (str == "mar") {
        n += 3;
    } else if (str == "apr") {
        n += 4;
    } else if (str == "may") {
        n += 5;
    } else if (str == "jun") {
        n += 6;
    } else if (str == "jly") {
        n += 7;
    } else if (str == "aug") {
        n += 8;
    } else if (str == "sep") {
        n += 9;
    } else if (str == "oct") {
        n += 10;
    } else if (str == "nov") {
        n += 11;
    } else if (str == "dec") {
        n += 12;
    } else {
        n = -1;
    }
    return n;
}

int DQ2(string str) {
    int n = 0;
    if (str == "tam") {
        n += 1;
    } else if (str == "hel") {
        n += 2;
    } else if (str == "maa") {
        n += 3;
    } else if (str == "huh") {
        n += 4;
    } else if (str == "tou") {
        n += 5;
    } else if (str == "kes") {
        n += 6;
    } else if (str == "hei") {
        n += 7;
    } else if (str == "elo") {
        n += 8;
    } else if (str == "syy") {
        n += 9;
    } else if (str == "lok") {
        n += 10;
    } else if (str == "mer") {
        n += 11;
    } else if (str == "jou") {
        n += 12;
    }
    return n;
}
int main() {
    int n;
    cin >> n;
    getchar();
    for (int i = 0; i < n; i++) {
        string str;
        getline(cin, str);
        if (str[0] >= '0' && str[0] <= '9') {
            HX(str);
        } else {
            if (str.length() <= 4) {
                int m = DQ(str);
                if (m == -1) {
                    m = DQ2(str);
                    m *= 13;
                }
                cout << m << endl;
            } else {
                string str2;
                str2 = str.substr(0, str.find(' '));
                int m = DQ2(str2);
                m *= 13;
                str2 = str.substr(str.find(' ') + 1, str.length());
                m += DQ(str2);
                cout << m << endl; 
            }
        }
    }
    return 0;
}

猜你喜欢

转载自blog.csdn.net/qq_39227338/article/details/80392066