People on Mars count their numbers with base 13:

  • Zero on Earth is called "tret" on Mars.
  • The numbers 1 to 12 on Earch is called "jan, feb, mar, apr, may, jun, jly, aug, sep, oct, nov, dec" on Mars, respectively.
  • For the next higher digit, Mars people name the 12 numbers as "tam, hel, maa, huh, tou, kes, hei, elo, syy, lok, mer, jou", respectively.

For examples, the number 29 on Earth is called "hel mar" on Mars; and "elo nov" on Mars corresponds to 115 on Earth. In order to help communication between people from these two planets, you are supposed to write a program for mutual translation between Earth and Mars number systems.

Input Specification:

Each input file contains one test case. For each case, the first line contains a positive integer N (< 100). Then N lines follow, each contains a number in [0, 169), given either in the form of an Earth number, or that of Mars.

Output Specification:

For each number, print in a line the corresponding number in the other language.

Sample Input:

4
29
5
elo nov
tam

Sample Output:

hel mar
may
115
13
 #include<stdio.h>
#include<string>
#include<iostream>
#include<string.h>
#include<sstream>
#include<vector>
#include<map>
using namespace std;
char firwei[][]={"tret","jan", "feb", "mar", "apr", "may", "jun", "jly", "aug", "sep", "oct", "nov", "dec"};
char secwei[][]={"tret","tam", "hel", "maa", "huh", "tou", "kes", "hei", "elo", "syy", "lok", "mer", "jou"};
map<string,int> mm1,mm2;
void toMar(int n)
{
vector<string> vv;
vv.push_back(firwei[n%]);
n = n / ;
if(n > )
{
vv.push_back(secwei[n]);
}
bool fir = ;
for(int i = vv.size() - ; i >= ;--i )
{
if(fir)
{
cout << vv[i];
fir = ;
}
else if( vv [i] != "tret" )cout << " " << vv[i] ;
}
cout << endl;
} int main()
{
int n;
for(int i = ;i < ;++i)
{
mm1[firwei[i]] = i;
}
for(int i = ;i < ;++i)
{
mm2[secwei[i]] = i;
}
scanf("%d",&n);
getchar();
string str;
for(int i = ;i < n;++i)
{
getline(cin,str);
if(str[]>='' && str[] <= '')
{
int num;
stringstream ss;
ss << str;
ss >> num;
toMar(num);
}
else
{
stringstream ss;
vector<string> svv;
string num;
int sum = ;
ss << str;
while(ss >> num)
{
svv.push_back(num);
}
if(svv.size() > )
{
sum = sum* + mm2[svv[]];
sum = sum* + mm1[svv[]];
}
else
{
sum = sum* + mm2[svv[]];
sum = sum* + mm1[svv[]];
}
printf("%d\n",sum);
}
}
return ;
}

1100. Mars Numbers (20)的更多相关文章

  1. PAT (Advanced Level) 1100. Mars Numbers (20)

    简单题. #include<cstdio> #include<cstring> #include<cmath> #include<vector> #in ...

  2. PAT甲级题解-1100. Mars Numbers (20)-字符串处理

    没什么好说的,注意字符串的处理,以及当数字是13的倍数时,只需高位叫法的单词.比如26,是“hel”,而不是“hel tret”. 代码: #include <iostream> #inc ...

  3. 【PAT甲级】1100 Mars Numbers (20 分)

    题意: 输入一个正整数N(<100),接着输入N组数据每组包括一行字符串,将其翻译为另一个星球的数字. AAAAAccepted code: #define HAVE_STRUCT_TIMESP ...

  4. pat1100. Mars Numbers (20)

    1100. Mars Numbers (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue People o ...

  5. PAT甲级——1100 Mars Numbers (字符串操作、进制转换)

    本文同步发布在CSDN:https://blog.csdn.net/weixin_44385565/article/details/90678474 1100 Mars Numbers (20 分) ...

  6. pat 1100 Mars Numbers(20 分)

    1100 Mars Numbers(20 分) People on Mars count their numbers with base 13: Zero on Earth is called &qu ...

  7. PAT 1100 Mars Numbers[难]

    1100 Mars Numbers (20 分) People on Mars count their numbers with base 13: Zero on Earth is called &q ...

  8. 1100 Mars Numbers——PAT甲级真题

    1100 Mars Numbers People on Mars count their numbers with base 13: Zero on Earth is called "tre ...

  9. 1100 Mars Numbers(20 分)

    People on Mars count their numbers with base 13: Zero on Earth is called "tret" on Mars. T ...

随机推荐

  1. iOS之GCD的DEMO

    由DEMO得知,串行队列同步执行会按照顺序一步一步执行,不会开辟线程 由DEMO得知,串行队列异步执行,队列中的任务会一步一步按顺序执行,队列外的任务不确定.会开辟线程 由DEMO得知,并行队列同步执 ...

  2. windws 安装jdk

    (1) 到官网下载好jdk:http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html (2 ...

  3. Linux chmod command

    @ chmod改变一个或多个文件的存取模式 chmod [options] mode files 只有文件属主或特殊用户才能使用该功能来改变文件存取模式.mode可以是数字形式或who opcode ...

  4. 页面modal服务

    /** * * * 初始化: * var oneModal = modalSvc.createModal(templateUrl, controller, size); * size可以是:lg或sm ...

  5. hdu 4725 最短路

    思路:将每个layer拆成两个点,编号为N+x,和N+N+x.对所有属于layer   x的点i,建N+x到i的有向边,在建i到N+N+x的有向边.最后对所有x号layer和x+1建一条N+N+x到N ...

  6. 开启Microsoft SQL Management时,如果出现"未能加载包

    Ms Sql server 2005在开启Microsoft SQL Management时,如果出现"未能加载包“Microsoft SQL Management Studio Packa ...

  7. sysobjects.xtype介绍

    SQL Server数据库的一切信息都保存在它的系统表格里. 在大多数情况下,对你最有用的两个列是Sysobjects.name和Sysobjects.xtype.前面一个用来列出待考察对象的名字,而 ...

  8. Filter的执行顺序及实例

    学习中的收藏,该文出自http://www.cnblogs.com/Fskjb/archive/2010/03/27/1698448.html 在此,非常感谢该文章作者的分享,本文完全转载自上面链接, ...

  9. 跟我学习dubbo-简介(1)

    1. Dubbo是什么? Dubbo是一个分布式服务框架,致力于提供高性能和透明化的RPC远程服务调用方案,以及SOA服务治理方案.简单的说,dubbo就是个服务框架,如果没有分布式的需求,其实是不需 ...

  10. SQL Server 2008安装失败问题以及解决办法

    一.检测过程中重启失败解决办法 在键盘上按下组合键[Win]+[R],调出运行窗口. 在窗口中输入“regedit”,点击确定,打开注册表管理界面. 在注册表左侧目录栏中找到如下位置:“HKEY_LO ...