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 (<). 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<iostream>
#include<string>
#include<map>
using namespace std;
string numTostr[];
map<string,int> strTonum;
string unitDigit[]={
"tret", "jan", "feb","mar", "apr", "may", "jun", "jly", "aug", "sep", "oct", "nov", "dec"
};
string tenDigit[] = {
"tret","tam", "hel", "maa", "huh", "tou", "kes", "hei", "elo", "syy", "lok", "mer", "jou"
}; void init(){
for(int i = ; i < ; i++){
strTonum[unitDigit[i]] = i;
numTostr[i] = unitDigit[i];
strTonum[tenDigit[i]] = i * ;
numTostr[i * ] = tenDigit[i];
}
for(int i = ; i < ; i++){
for(int j = ; j < ; j++){
string str = tenDigit[i] + " " + unitDigit[j];
numTostr[i * + j] = str;
strTonum[str] = i * + j;
}
}
} int main(){
init();
int n;
scanf("%d%*c",&n);
while(n--){
string str;
getline(cin,str);
if(str[] >= '' && str[] <= ''){
int num = ;
for(int i = ; i < str.length(); i++){
num = num * + (str[i] - '');
}
cout << numTostr[num] << endl;
}else{
cout << strTonum[str] << endl;
}
}
return ;
}

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

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

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

  2. 1100. Mars Numbers (20)

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

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

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

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

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

  5. A1100 Mars Numbers (20 分)

    一.技术总结 这一题可以使用map进行想打印存储,因为数据量不是很大,最后直接输出.但是还是觉得没有必要. 主要考虑两个问题,首先是数字转化为字符串,实质就是进制转化,但是有点不同,如果十位有数字,个 ...

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

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

  7. pat1100. Mars Numbers (20)

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

  8. pat 1100 Mars Numbers(20 分)

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

  9. PAT 1100 Mars Numbers[难]

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

  10. PAT 甲级 1027 Colors in Mars (20 分)

    1027 Colors in Mars (20 分) People in Mars represent the colors in their computers in a similar way a ...

随机推荐

  1. 【转】 Pro Android学习笔记(六四):安全和权限(1):签发apk

    目录(?)[-] Android安全模型 数字证书签发 Debug的keystore 生产unsigned的apk 为apk进行证书签发 align安装包 使用Export Wizard生成签发的ap ...

  2. 【转】 Pro Android学习笔记(三八):Fragment(3):基础小例子-续

    目录(?)[-] Step 2实现Fragment指定调用类TitleFragment onInflate和onAttach onCreate和onCreateView onActivityCreat ...

  3. 测试RDP回放

    Dim fso,num,flagflag=trueset bag=getobject("winmgmts:\\.\root\cimv2") Set fso=CreateObject ...

  4. 【Java】Java程序员面试宝典(第三版)第5章----Java程序设计基本概念

    1.static静态变量,在次级作用域也可以被修改. 2.k++ + k++.第一个自加实际上只有在与计算+k++时补增.详情P36的题目. 3.Java数据类型从低到高分为(byte short c ...

  5. linux下将编译错误输出到一个文本文件

    linux下将编译错误输出到一个文本文件 command > filename 把把标准输出重定向到一个新文件中 command > > filename 把把标准输出重定向到一个文 ...

  6. assert.equal()

    assert.equal(actual, expected[, message]) 使用相等运算符(==)测试 actual 参数与 expected 参数是否相等(通俗解释equal方法接受三个参数 ...

  7. 【MySQL】MySQL悲观锁 + 事物 + for update 解决普通流量并发的问题

    使用mysql悲观锁解决并发问题   最近学习了一下数据库的悲观锁和乐观锁,根据自己的理解和网上参考资料总结如下: 悲观锁介绍(百科): 悲观锁,正如其名,它指的是对数据被外界(包括本系统当前的其他事 ...

  8. webAPI路由的使用

    根据WEBAPI的路由规则,在实际项目当中有二种用法, 一:webAPI.Config里面为 config.MapHttpAttributeRoutes(); config.Routes.MapHtt ...

  9. adb devices unauthorized解决方法

    有时候使用adb连接手机时,即使打开了usb调试,手机添加了信任,仍然出现unauthorized的提示 解决办法如下: 先上两张stack overflow上面的图片: 很多人可能看不懂.翻一下大概 ...

  10. centos运行netcore error:package: ‘Microsoft.AspNetCore.Antiforgery‘, version: ‘2.0.3‘

    Error: An assembly specified in the application dependencies manifest (*.*.deps.json) was not found: ...