这个考察的是map的使用吧,字符串映射数字。
附本人AC代码:
#include<iostream>
#include<map>
#include<cctype>
#include<string>
using namespace std;
map<string, int>Ma1,Ma2;
string name1[13] = { "tret","jan","feb","mar","apr","may","jun","jly","aug","sep","oct","nov","dec" };
string name2[13] = { "tret","tam", "hel", "maa", "huh", "tou", "kes", "hei", "elo", "syy", "lok", "mer", "jou" };
int main() {
for (int i = 0; i < 13; i++) {
Ma1[name1[i]] = i;
Ma2[name2[i]] = 13*i;
}
int N;
string tmp;
scanf("%d", &N);
cin.ignore();
for (int i = 0; i < N; i++) {
getline(cin,tmp);
if (isdigit(tmp[0])) {
int t = stoi(tmp);
if (t / 13 != 0)printf("%s", name2[t / 13].c_str());
if (t / 13 != 0 && t % 13 != 0)printf(" ");
if(t%13!=0||t/13==0)printf("%s", name1[t % 13].c_str());
printf("\n");
}
else {
int ans = 0;
if (tmp.find(' ') != tmp.npos) {
ans += Ma2[tmp.substr(0, tmp.find(' '))] + Ma1[tmp.substr(tmp.find(' ') + 1)];
printf("%d\n", ans);
}
else if (Ma1[tmp]!= 0)printf("%d\n", Ma1[tmp]);
else printf("%d\n", Ma2[tmp]);
}
}
return 0;
}