题意:进制转换。

思路:注意当数字是13的倍数时,只需高位叫法的单词。比如26,是“hel”,而不是“hel tret”。我被坑在这里了!对应语句1的处理。另外,在输入n和n个字符串之间需要一个吸收字符的函数,这个也搞了半天!

数字转字符串时:需要考虑(1)0~12;(2)13,26等13的倍数;(3)29,115等常规情况。

字符串转数字时:需要考虑(1)tret;(2)xxx xxx;(3)xxx,其中这一类又分为低位和高位两种可能,低位的话可直接输出,高位的话要乘base(即13)。

代码:

#include <iostream>
#include <string>
#include <unordered_map>
#include <vector>
#include <ctype.h>
using namespace std;

vector<string> low={"tret","jan", "feb", "mar", "apr", "may", "jun", "jly", "aug", "sep", "oct", "nov", "dec"};
vector<string> high={"","tam", "hel", "maa", "huh", "tou", "kes", "hei", "elo", "syy", "lok", "mer", "jou"};
unordered_map<string,int> strToInt_g;//个位
unordered_map<int,string> intToStr_g;
unordered_map<string,int> strToInt_s;//十位
unordered_map<int,string> intToStr_s;

void init()
{
    ;i<;i++){
        strToInt_g.insert(make_pair(low[i],i));
        intToStr_g.insert(make_pair(i,low[i]));
    }
    ;i<;i++){
        strToInt_s.insert(make_pair(high[i],i));
        intToStr_s.insert(make_pair(i,high[i]));
    }
}

int main()
{
    init();
    int n;
    cin>>n;
    getchar();//!!!
    string str;
    while(n--){
        getline(cin,str);
        ])){
            int val=stoi(str);
            int h,l;
            h=val/;//高位
            l=val%;//低位
             && l!=) cout<<high[h]<<' '<<low[l]<<'\n';
             && l==) cout<<high[h]<<'\n';//语句1
            else cout<<low[l]<<'\n';
        }else{
            ){
                ) cout<<<<'\n';
                else{
                    ,);
                    ,);
                    cout<<strToInt_s[shi]*+strToInt_g[ge]<<'\n';
                }
            }else{
                ) cout<<strToInt_g[str]<<'\n';
                <<'\n';
            }
        }
    }
    ;
}

最新文章

  1. .NET Core 和 .NET Framework 之间的关系
  2. setContentView R can not be resovled
  3. 使用TCMalloc的堆栈检查
  4. C/C++多种方法获取文件大小(转)
  5. 线性时间的排序算法--桶排序(以leetcode164. Maximum Gap为例讲解)
  6. Spark Streaming官方文档学习--上
  7. Codeforces Round #336 (Div. 2)A. Saitama Destroys Hotel 水题
  8. backboneJs 导图
  9. Xcode - 必不可少的插件
  10. java中函数是值传递还是引用传递?
  11. spring 内部工作机制(一)
  12. cin\cout输入输出控制
  13. word里面对齐用Tab键
  14. [JavaScript]ECMA-6 箭头函数
  15. 【C++】类中this指针的理解
  16. 记录 spf13-vim 遇到的问题
  17. (记录合并)union和union all的区别
  18. HTML的代码规范
  19. C语言程序设计基础知识点概括
  20. Oracle正在执行和执行过的SQL语句

热门文章

  1. Springer Latex投稿
  2. FM算法 的总结
  3. 20165332实验三 敏捷开发与XP实践
  4. 51nod 1406 位运算/dp
  5. linux rpm命令安装卸载 初步使用
  6. 【Wannafly挑战赛10 - B】小H和密码(DP)
  7. LeetCode OJ:Simplify Path(简化路径)
  8. phpcms ——模板标签使用说明
  9. ROS中使用ABB Yumi IRB14000的一些资料汇总
  10. fedora to ubunto