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. YTU 2760: 字符串---首字母变大写

    2760: 字符串---首字母变大写 时间限制: 1 Sec  内存限制: 128 MB 提交: 343  解决: 136 题目描述 输入一行英文句子,将每个单词的第一个字母改成大写字母. 输入 一个 ...

  2. XAML实例教程系列 - 命名空间(NameSpace) 三

    XAML实例教程系列 - 命名空间(NameSpace) 2012-05-28 14:14 by jv9, 2205 阅读, 10 评论, 收藏, 编辑 上一篇曾提及XAML中,每个对象元素的声明是对 ...

  3. JavaScript 中String和int互相转换

    在javascript里怎么样才能把int型转换成string型 (1) var num = 0;    a = x.toString();    (2) var x = 0;    a = x + ...

  4. 数据清洗——python定位csv中的特定字符位置

    之前发过一篇关于定位csv中的特殊字符的,主要是用到了python的自带的函数,近期又遇到了一些新的问题,比如isdigit()的缺点在于不能判断浮点型,以及小数中有多个小数点的情况.发现还是正则表达 ...

  5. Linq学习(四)-联合查询

    一.本将主要介绍 Union.Concat.Intersect.Except的使用操作 1.Union 查询昵称中带有Friend和带有Lee的用户 Linq (from a in Blog_User ...

  6. 6.11---multipartfile在哪个jar包下---6.11---uuid---swagger上传图片包错去掉注解响应体

    <dependency><groupId>commons-fileupload</groupId><artifactId>commons-fileupl ...

  7. drupal 8——图片组(list)在前台的显示顺序在登录状态和非登录状态不同

    问题描述:该页面是通过view来输出的,然而,登录状态下其页面中的图片组输出顺序是乱序的,而非登录状态下则根据id值升序输出. 原因:在原view配置页面中,没有配置默认的排序字段 解决方案:在vie ...

  8. drupal 8 ——自定义权限

    在项目开发里面,我遇到了这么一个需求,就是对于node的title字段,编辑内容的角色不允许对title进行编辑.title字段是创建内容类型时自动生成的字段,不能在drupal8后台直接配置权限,所 ...

  9. 客户端通过base64上传bitmap服务器

    首先致谢:http://www.jb51.net/article/129743.htm 咱们不是代码的生产者,只是代码的搬运工. 场景描述:Android客户端需要上传头像等图片到服务器,经双方协商决 ...

  10. Android 6.0一个完整的native service

     上一篇博客<Android 6.0 如何添加完整的系统服务(app-framework-kernel)>http://www.cnblogs.com/hackfun/p/7418902. ...