//部分正确?
//
#include "stdafx.h"
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
const vector<string> low_mars = {"tret", "jan", "feb", "mar", "apr", "may", "jun", "jly", "aug", "sep", "oct", "nov", "dec" };
const vector<string> high_mars = { "", "tam", "hel", "maa", "huh", "tou", "kes", "hei", "elo", "syy", "lok", "mer", "jou" };
unsigned mars_to_earth(string m, string n)
{
unsigned ret=0;
if (!m.empty() && find(high_mars.begin(), high_mars.end(), m)!=high_mars.end())
{
auto tmp = find(high_mars.begin(), high_mars.end(), m) - high_mars.begin();
ret = ret + tmp * 13;
}
if (!n.empty() && find(low_mars.begin(), low_mars.end(), n)!=low_mars.end())
{
auto tmp = find(low_mars.begin(), low_mars.end(), n) - low_mars.begin();
ret = ret + tmp;
}
return ret;
}
string earth_to_mars(unsigned k)
{
unsigned high = k / 13;
unsigned low = k % 13;
string ret;
if (high > 0)
{
ret = high_mars[high] + " ";
if (low > 0)
{
ret = ret + low_mars[low];
}
}
else
{
ret = ret + low_mars[low];
}
return ret;
}
int main()
{
unsigned n;
cin >> n;
cin.ignore();
string str;
for (unsigned i = 0; i < n; ++i)
{
getline(cin, str);
if (isalpha(str[0]))
{
string m, n;
if (str.find(" ") != string::npos)
{
m = str.substr(0, str.find(" "));
n = str.substr(str.find(" ") + 1, string::npos);
}
else
{
m = str;
n = str;
}
cout << mars_to_earth(m, n);
}
else
{
unsigned k = stoul(str);
cout << earth_to_mars(k);
}
if ((n - 1) != i)
{
cout << endl;
}
}
system("pause");
return 0;
}
1044
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...