这题还真是坑人。
比如 26 转化成火星文,有了高位,就不要低位了,这种情况要单独讨论。
#include<bits/stdc++.h> using namespace std; int main() { string a[13] = {"tret", "jan", "feb", "mar", "apr", "may", "jun", "jly", "aug", "sep", "oct", "nov", "dec"}; string b[13] = {"##", "tam", "hel", "maa", "huh", "tou", "kes", "hei", "elo", "syy", "lok", "mer", "jou"}; map<string, int> mapp1 = {{"tret", 0}, {"jan", 1}, {"feb", 2}, {"mar", 3}, {"apr", 4}, {"may", 5}, {"jun", 6}, {"jly", 7}, {"aug", 8}, {"sep", 9}, {"oct", 10}, {"nov", 11}, {"dec", 12}}; map<string, int> mapp2 = {{"##", 0}, {"tam", 1}, {"hel", 2}, {"maa", 3}, {"huh", 4}, {"tou", 5}, {"kes", 6}, {"hei", 7}, {"elo", 8}, {"syy", 9}, {"lok", 10}, {"mer", 11}, {"jou", 12}}; int n, j; string s; cin >> n; getchar(); for(int i = 0; i < n; i ++) { getline(cin, s); if(isalpha(s[0])) { if(s.size() > 6) cout << mapp2[s.substr(0, 3)] * 13 + mapp1[s.substr(4)] << endl; else { if(mapp1.count(s)) cout << mapp1[s] << endl; else cout << mapp2[s] * 13 << endl; } } else { if(stoi(s) / 13 != 0 && stoi(s) % 13 == 0) cout << b[stoi(s) / 13] << endl; else if(stoi(s) / 13 != 0 && stoi(s) % 13 != 0) cout << b[stoi(s) / 13] << " " << a[stoi(s) % 13] << endl; else if(stoi(s) / 13 == 0) cout << a[stoi(s)] << endl; } } return 0; }