火星人是以  进制计数的:

地球人的  被火星人称为 tret。
地球人数字 到 的火星文分别为:jan, feb, mar, apr, may, jun, jly, aug, sep, oct, nov, dec。
火星人将进位以后的 个高位数字分别称为:tam, hel, maa, huh, tou, kes, hei, elo, syy, lok, mer, jou。
例如地球人的数字 翻译成火星文就是 hel mar;而火星文 elo nov 对应地球数字 。为了方便交流,请你编写程序实现地球和火星数字之间的互译。 输入格式:
输入第一行给出一个正整数 N(<),随后 N 行,每行给出一个 [, ) 区间内的数字 —— 或者是地球文,或者是火星文。 输出格式:
对应输入的每一行,在一行中输出翻译后的另一种语言的数字。 输入样例: elo nov
tam
输出样例:
hel mar
may
#include <iostream>
#include <sstream>
#include <cctype>
#include <cmath>
#include <vector>
using namespace std;
int main()
{
string s;int num;
string ge[]={"tret","jan","feb","mar","apr","may","jun","jly","aug","sep","oct","nov","dec"};
string shi[]={"","tam","hel","maa","huh","tou","kes","hei","elo","syy","lok","mer","jou"};
cin>>num;getline(cin,s);
while(num--){
getline(cin,s);
stringstream ss;
if(isdigit(s[])){
int digit;
ss<<s;
ss>>digit;
string res="";
int geDi=digit%;
int shDi=digit/;
bool hasPrintShi=false;
if(shDi!=) {
res+=shi[shDi];
res+=" ";
hasPrintShi=true;
}
if(!(hasPrintShi&&geDi==)) {
res+=ge[geDi];
res+=" ";
}
cout<<res.substr(,res.length()-)<<endl;
}else{
ss<<s;
string tmp;
vector<string> vec;
while(ss>>tmp) vec.push_back(tmp);
int a=;
while(vec.size()!=){
for(int i=;i<;i++){
if(shi[i]==vec[]){
a=i*;
vec.erase(vec.begin());
break;
}
if(ge[i]==vec[]){
a+=i;
vec.erase(vec.begin());
break;
}
}
}
cout<<a<<endl;
}
}
system("pause");
return ;
}

最新文章

  1. 初识SpringMvc
  2. 配置Java SSL 访问网站证书
  3. HttpURlconntiuon获取网络数据
  4. [Gnu]Centos7 解决 gdb 提示 Missing separate debuginfos
  5. EF架构~linq模拟left join的两种写法,性能差之千里!
  6. 深入理解CSS中的空白符和换行
  7. Rename in Batch [Python]
  8. iOS开发之 Xcode 5 下让你的应用在不同状态(debug, release)有不同的图标
  9. Android中使用shape实现EditText圆角
  10. oracle 集合变量以及自定义异常的用法
  11. ASP.NET CORE系列【六】Entity Framework Core 之数据库迁移
  12. android 4G产品4G网络问题记录
  13. Java KeyStore 用命令生成keystore文件
  14. python open 函数的读写追加
  15. 2017-12-15python全栈9期第二天第七节之练习题
  16. Linux安装Tomcat-Nginx-FastDFS-Redis-Solr-集群——【第九集之安装Tomcat+Nginx反向代理Tomcat集群】
  17. why deep learning works
  18. 玩具谜题(NOIP2016)
  19. 2019.01.02 poj1322 Chocolate(生成函数+二项式定理)
  20. MVC ---- EF批处理

热门文章

  1. JAVA 面向对象编程 --自我总结
  2. springboot-RequestMappingHandlerMapping
  3. Es性能优化
  4. ubuntu14.04 安装 zoom.us
  5. 【并行计算-CUDA开发】__syncthreads的理解
  6. NDK学习笔记-JNI开发流程
  7. spy++工具
  8. Django模块
  9. 「java.util.concurrent并发包」之 ThreadPoolExecutor
  10. Vue.js学习笔记-script标签在head和body的区别