PAT甲级——A1100 Mars Numbers
People on Mars count their numbers with base 13:
- Zero on Earth is called "tret" on Mars.
- The numbers 1 to 12 on Earth 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<bits/stdc++.h>
using namespace std;
int main(){
string low[]={//数字到火星文低位的映射
"tret","jan","feb","mar", "apr", "may", "jun", "jly", "aug", "sep", "oct", "nov", "dec"};
string high[]={//数字到火星文高位的映射
"tret","tam", "hel", "maa", "huh", "tou", "kes", "hei", "elo", "syy", "lok", "mer", "jou"};
unordered_map<string,int>temp;//火星文到数字的映射
for(int i=;i<;++i){
temp[low[i]]=i;
temp[high[i]]=i*;
}
int n;
scanf("%d%*c",&n);
string digit="";
while(n--){
getline(cin,digit);
if(isdigit(digit[])){//如果是数字
int k=stoi(digit);
if(k/!=)//高位不为0,输出高位
printf("%s",high[k/].c_str());
if(k/!=&&k%!=)//高位低位均不为0,输出空格
printf(" ");
if(k/==||k%!=)//高位为0或者高位不为0但低位为0时,输出低位
printf("%s",low[k%].c_str());
puts("");//换行
}else{//是火星文
int k=;
stringstream stream(digit);
while(stream>>digit)//按空格键分割字符串
k+=temp[digit];
printf("%d\n",k);
}
}
return ;
}
PAT甲级——A1100 Mars Numbers的更多相关文章
- PAT甲级——1100 Mars Numbers (字符串操作、进制转换)
本文同步发布在CSDN:https://blog.csdn.net/weixin_44385565/article/details/90678474 1100 Mars Numbers (20 分) ...
- A1100. Mars Numbers
People on Mars count their numbers with base 13: Zero on Earth is called "tret" on Mars. T ...
- PAT甲级 1120. Friend Numbers (20)
1120. Friend Numbers (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Two in ...
- PAT甲级——A1120 Friend Numbers【20】
Two integers are called "friend numbers" if they share the same sum of their digits, and t ...
- A1100 Mars Numbers (20 分)
一.技术总结 这一题可以使用map进行想打印存储,因为数据量不是很大,最后直接输出.但是还是觉得没有必要. 主要考虑两个问题,首先是数字转化为字符串,实质就是进制转化,但是有点不同,如果十位有数字,个 ...
- PAT_A1100#Mars Numbers
Source: PAT A1100 Mars Numbers (20 分) Description: People on Mars count their numbers with base 13: ...
- 1100 Mars Numbers——PAT甲级真题
1100 Mars Numbers People on Mars count their numbers with base 13: Zero on Earth is called "tre ...
- PAT 1100 Mars Numbers[难]
1100 Mars Numbers (20 分) People on Mars count their numbers with base 13: Zero on Earth is called &q ...
- pat 1100 Mars Numbers(20 分)
1100 Mars Numbers(20 分) People on Mars count their numbers with base 13: Zero on Earth is called &qu ...
随机推荐
- Dribbble 流行的配色风格是什么?
Dribbble 是众所周知的设计社群网站,在网站中有许多人分享设计作品,互相交流或从其他设计获取灵感.当然也有不少网站应运而生,例如 Freebbble 可免费下载 Dribbble 数千种设计素材 ...
- shell 命令 修改文件权限 chmod
1. 所有者+.-权限 更改那个拥有者的权限 u 表示文件的所有者 g 表示文件所在的组 o 表示其他用户 a 所有,以上三者 增加 / 减少权限 + 表示增加权限 - 表示取消权限 更改具体 ...
- BeanPostProcessor原理--使用讲解
<Spring源码解析>笔记 BeanPostProcessor原理学习 在学习BeanPostProcessor的原理学习完之后,对Spring如何使用充满好奇,尝试使用例子进行理解,以 ...
- linux shell下除了某个文件外的其他文件全部删除的命令
Linux反选删除文件 最简单的方法是 # shopt -s extglob (打开extglob模式) # rm -fr !(file1) 如果是多个要排除的,可以这样: # rm -r ...
- php设置时区和strtotime转化为时间戳函数
date_default_timezone_set('PRC');//设置中华人民共和国标准时间 strtotime — 将任何英文文本的日期时间描述解析为 Unix 时间戳 格式:int strto ...
- jdk配置到tomcat配置
1.jdk配置 首先下载jdk 这里我下载的是 jdk1.8 (jdk1.8.0_181\) 然后,安装 我的安装路径 C:\Program Files\Java\jdk1.8.0_181\ 我选择默 ...
- linux中对EINTR错误的处理
https://www.cnblogs.com/flyfish10000/articles/2576885.html EINTR错误的产生:当阻塞于某个慢系统调用的一个进程捕获某个信号且相应信号处理函 ...
- Kafka和RabbitMQ 对比
1) Kafka成为业界大数据松耦合架构,异步,队列 特点:吞吐量高50m/s. Kafka和RabbitMQ都是MQ机制,它差异 Kafka作为大数据产品,可以作为数据源,也可以作为结果数据中转 ...
- System.Web.Mvc.HttpPostAttribute.cs
ylbtech-System.Web.Mvc.HttpPostAttribute.cs 1.程序集 System.Web.Mvc, Version=5.2.3.0, Culture=neutral, ...
- Static 关键字的 5 种用法,你会几种?
); System.out.println(Thread.currentThread().getName() ...