## Siukwan Program

http://siukwan.sinaapp.com/

# 1100. Mars Numbers (20)

1.十进制与13进制之间的转换

2.注意输入为13，26，39整数时，只输出一个marsNum，后面低位的0不输出

AC代码：

//#include<string>
//#include <iomanip>
#include<vector>
#include <algorithm>
//#include<stack>
#include<set>
#include<queue>
#include<map>
//#include<unordered_set>
#include<unordered_map>
//#include <sstream>
//#include "func.h"
//#include <list>
#include<stdio.h>
#include<iostream>
#include<string>
#include<memory.h>
#include<limits.h>
using namespace std;
bool isNum(string a)
{
for (int i = 0; i < a.size(); i++)
{
if (a[i]>'9' || a[i] < '0')
return false;
}
return true;
}
int main(void)
{
vector<string> marsNum = { "tret","jan", "feb", "mar", "apr", "may", "jun", "jly", "aug", "sep", "oct", "nov", "dec" };
vector<string> marsNum2 = { "tam", "hel", "maa", "huh", "tou", "kes", "hei", "elo", "syy", "lok", "mer", "jou" };
map<string, int> mars2Num;
map<string, int> mars2Num2;
for (int i = 0; i < marsNum.size(); i++)
{
mars2Num[marsNum[i]] = i;
}
for (int i = 0; i < marsNum2.size(); i++)
{
mars2Num2[marsNum2[i]] = i+1;
}
string str = "";
string n = "";
getline(cin, n);
int sum = 0;
for (int i = 0; i < n.size(); i++)
{
sum = sum * 10 + n[i] - '0';
}
for (int k = 0; k < sum; k++)
{
getline(cin, str);
if (isNum(str))
{
int num = 0;
for (int i = 0; i < str.size(); i++)
{
num = num * 10 + str[i] - '0';
}
string ans = "";
int  low = num % 13;//计算高位和地位
int  high = num / 13;
if (high == 0)
ans = marsNum[low];
else if (low == 0)//注意输入为13，26，39整数时，只输出一个marsNum，后面低位的0不输出
ans = marsNum2[high - 1] ;
else
ans = marsNum2[high - 1] + " " + marsNum[low];
cout << ans << endl;
}
else
{
int ans = 0;
if (str.size() == 3)
{
if (mars2Num.find(str) != mars2Num.end())
{
ans = mars2Num[str];
}
else
{//找不到，是在十位上
ans = mars2Num2[str]*13;
}
}
else
{
string high = str.substr(0, 3);
string low = str.substr(4);
ans = mars2Num2[high] * 13 + mars2Num[low];
}
cout << ans << endl;
}
}
return 0;
}


#### PAT 1100. Mars Numbers (20)

2016-02-29 12:26:59

#### 1100. Mars Numbers (20) / 1044. 火星数字(20), 字符串坑

2015-09-18 10:37:49

#### 1100.Mars Numbers (20)...to be continued...

2017-02-20 21:20:58

#### 1100. Mars Numbers (20)-PAT甲级真题

2016-07-21 19:23:48

#### 1100. Mars Numbers (20)

2016-11-14 13:34:51

#### 【PAT】1100. Mars Numbers (20)

2015-10-08 20:21:18

#### 1100. Mars Numbers (20)

2017-10-30 13:28:07

#### 1044. 火星数字(20)PAT乙级&&1100. Mars Numbers (20)PAT甲级

2017-02-02 20:29:20

#### 1100. Mars Numbers (20)[字符处理]

2017-05-08 09:19:42

#### 1100. Mars Numbers (20)解题报告

2016-12-30 13:53:23