1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
| #include <iostream> #include <ctype.h> using namespace std; string num[2][13] = { {"tret", "jan", "feb", "mar", "apr", "may", "jun", "jly", "aug", "sep", "oct", "nov", "dec"}, {"tret", "tam", "hel", "maa", "huh", "tou", "kes", "hei", "elo", "syy", "lok", "mer", "jou"} }; void C(string& str) { int n = atoi(str.data()); string ans; int count = 0; for (int tn = n; tn; tn /= 13, count++); if (count == 1 || count == 0) ans = num[0][n]; else ans = num[1][n / 13] + ((n % 13 != 0) ? (" " + num[0][n % 13]) : ""); cout << ans << endl; } int D(string& str) { if (str == "tret") return 0; string a, b; a = str.substr(0, 3); if (str.length() > 3) b = str.substr(4, str.length() - 3); if (b == "") { for (int i = 0; i < 13; i++) if (a == num[0][i]) return i; for (int i = 0; i < 13; i++) if (a == num[1][i]) return i * 13; } else { int n = 0; for (int i = 0; i < 13; i++) if (a == num[1][i]) n += i * 13; for (int i = 0; i < 13; i++) if (b == num[0][i]) n += i; return n; } } int main() { int n; cin >> n; getchar(); for (int i = 0; i < n; i++) { string temp; getline(cin, temp); if (!isalpha(temp[0])) C(temp); else cout << D(temp) << endl; } return 0; }
|