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<iostream>
#include<algorithm>
#include<vector>
#include<sstream>
using namespace std;
int main(){
vector<string> gewei{"tret","jan","feb","mar","apr","may","jun","jly","aug","sep","oct","nov","dec"};
vector<string> shiwei{"#","tam","hel","maa","huh","tou","kes","hei","elo","syy","lok","mer","jou"};
int N; cin>>N;
string s,str; int a,b,c;
getchar();
while(N--){
int sum=0;
getline(cin,s);
if(isdigit(s[0])){
c=stoi(s); // 将s转化为int
if(c<13)
cout<<gewei[c]<<endl;
else{
if(c%13==0) cout<<shiwei[c/13]<<endl; // 13的倍数是不要输出tret的
else cout<<shiwei[c/13]<<" "<<gewei[c%13]<<endl;
}
}
else{
istringstream is(s); // 利用istringstream读取s中的单词
while(is>>str){
auto it=find(shiwei.begin(),shiwei.end(),str);
if(it!=shiwei.end())
sum+=(it-shiwei.begin())*13;
auto itt=find(gewei.begin(),gewei.end(),str);
if(itt!=gewei.end())
sum+=(itt-gewei.begin());
}
cout<<sum<<endl;
}
}
return 0;
}

PAT 1100. Mars Numbers的更多相关文章

  1. PAT 1100 Mars Numbers[难]

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

  2. pat 1100 Mars Numbers(20 分)

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

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

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

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

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

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

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

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

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

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

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

  8. 1100. Mars Numbers (20)

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

  9. 1100 Mars Numbers(20 分)

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

随机推荐

  1. activiti安装-------安装插件

    对上面的放大

  2. frameset的target属性

    使用frameset时的target属性 (2012-09-18 08:19:31) 转载▼   分类: java技术之路 一般常用的有四个属性 _blank 浏览器总在一个新打开.未命名的窗口中载入 ...

  3. 洛谷P1250种树(贪心)

    题目描述 一条街的一边有几座房子.因为环保原因居民想要在路边种些树.路边的地区被分割成块,并被编号成1..N.每个部分为一个单位尺寸大小并最多可种一棵树.每个居民想在门前种些树并指定了三个号码B,E, ...

  4. robotframework - 运行报错提示 No keyword with name 'Open Browser' found.

    用下面的例子为例: 1.输入以上robot脚本提示: 2.经查阅资料,大部分都使用的是selenium2 版本,无法解该的问题,目前小编使用的是selenium3,不知道selenium是哪个版本的话 ...

  5. go 学习成长之路

    一.go的搭建 二.初识go 三.混个脸熟--go 四.go的语言结构 五.go的常量与变量 六.go基础数据类型 七.go 条件语句 八.go 运算符 九.go条件语句switch 十.go循环语句 ...

  6. composer 下载安装

    linux/mac os curl -sS https://getcomposer.org/installer | php mv composer.phar /usr/local/bin/compos ...

  7. Codeforces 19E 树上差分

    思路: 先随便建出来一棵搜索树(图可能不连通?) 每一条非树边(剩下的边)和树边都可以构成一个环. 我们只看一个非树边和某些树边构成的这些环. 分成三种情况: 1.没有奇环  所有边都可以删 2.有一 ...

  8. jQuery Tmpl使用

    1.引入脚本 2.编写模板 2.1假设此时有一个,从后台一json格式发送来的数据 [{"tId":1,"tName":"张三"," ...

  9. Python--10、进程知识补充

    守护进程 基于进程启动的子进程,会和主进程一起结束.主进程结束的依据是程序的代码执行完毕. #创建守护进程p=Process(task) p.daemon = True p.start() 子进程需要 ...

  10. Android 解决ScrollView嵌套RecyclerView导致滑动不流畅的问题

    最近做的项目中遇到了ScrollView嵌套RecyclerView,刚写完功能测试,直接卡出翔了,后来通过网上查找资料和 自己的实践,找出了两种方法解决这个问题. 首先来个最简单的方法: recyc ...