Skip to content

Commit 56aba33

Browse files
committed
feat: update 1100
1 parent 328b1dc commit 56aba33

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed

PAT/1100/main.cpp

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#define _CRT_SECURE_NO_WARNINGS
2+
#include <iostream>
3+
#include <string>
4+
using namespace std;
5+
string base[] = {
6+
"tret", "jan", "feb", "mar", "apr", "may", "jun",
7+
"jly", "aug", "sep", "oct", "nov", "dec",
8+
};
9+
string high[] = {
10+
"", "tam", "hel", "maa", "huh", "tou", "kes", "hei",
11+
"elo", "syy", "lok", "mer", "jou",
12+
};
13+
string mars(int n) {
14+
string s = "";
15+
if (n / 13 != 0) {
16+
s = high[n / 13];
17+
n = n - 13 * (n / 13);
18+
if (n != 0) {
19+
s = s + " " + base[n];
20+
}
21+
}
22+
else {
23+
s = base[n];
24+
}
25+
return s;
26+
}
27+
int earth(string s) {
28+
int num = 0;
29+
if (s.length() == 7) {
30+
string tmp = s.substr(0, 3);
31+
s = s.substr(4, 3);
32+
for (int i = 1; i < 13; i++) {
33+
if (high[i] == tmp) {
34+
num += i * 13;
35+
break;
36+
}
37+
}
38+
}
39+
for (int i = 0; i < 13; i++) {
40+
if (base[i] == s) {
41+
num += i;
42+
return num;
43+
}
44+
}
45+
for (int i = 1; i < 13; i++) {
46+
if (high[i] == s) {
47+
return i * 13;
48+
}
49+
}
50+
return -1;
51+
}
52+
int main() {
53+
int n = 0;
54+
cin >> n;
55+
cin.get();
56+
for (int i = 0; i < n; i++) {
57+
char num[8] = { 0 };
58+
int tmp = -1;
59+
cin.getline(num, 8);
60+
sscanf(num, "%d", &tmp);
61+
if (tmp != -1) {
62+
cout << mars(tmp) << endl;
63+
}
64+
else {
65+
cout << earth(num) << endl;
66+
}
67+
}
68+
return 0;
69+
}

0 commit comments

Comments
 (0)