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. DeepDive is a system to extract value from dark data.

    DeepDive is a system to extract value from dark data. http://deepdive.stanford.edu/

  2. SoapUI在Jenkins中的配置

    Jenkins Label: windows_ws_test   已有Jenkins环境变量 %READYAPI_PRO_HOME%  - <D:\Program Files\SmartBear ...

  3. 2017iOS开发最新的打包测试步骤(亲测)

    最近也是忙着修改项目,今天把最近遇到的问题和知识给大家分享一下. 有时候我们需要将我们的项目发给测试组进行bug测试,这时候我们就需要把自己的项目打包,生成一个二维码或者链接的形式,给测试组,接下来就 ...

  4. 修改select默认样式

    http://www.qkzone.com/code/2015-11-26/1.html

  5. cas4.2的安装

    cas4.2使用的是gradle来构建项目的,项目代码在https://github.com/Jasig/cas下载. 然后之后进入项目的根目录,然后执行gradle来编译项目,如下: gradle ...

  6. 37. ext 中sm什么意思

    转自:https://zhidao.baidu.com/question/112450217.htmlsm是SelectionModel的缩写默认为RowSelectionModel其他模式还有Che ...

  7. Android webkit keyevent 事件传递过程

    前言:基于android webview 上定制自己使用的可移植浏览器apk,遇到好多按键处理的问题.所以索性研究了一下keyevent 事件的传递流程. frameworks 层 keyevent ...

  8. Java初级进阶中高级工程师必备技能

    很多人学了javase以为自己学的已经很OK了,但是其实javase里边有很多的知识点是你不知道的,不管你找的是哪里的javase的视频,大多数是不会讲这些东西,而这些东西你平时业务又不会主动去接触, ...

  9. Vue电商SKU组合算法问题

    前段时间,公司要做“添加商品”业务模块,这也算是电商业务里面的一个难点了. 令我印象最深的不是什么“组合商品”.“关联商品”.“关联单品”,而是商品SKU的组合问题. 这个问题特别有意思,当时虽然大体 ...

  10. javascript中for...in和for...of的区别

    for...of循环是ES6引入的新的语法. for...in遍历拿到的x是键(下标).而for...of遍历拿到的x是值,但在对象中会提示不是一个迭代器报错.例子如下: let x; let a = ...