pat1100. Mars Numbers (20)
1100. Mars Numbers (20)
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<cstdio>
#include<cstring>
#include<iostream>
#include<stack>
#include<set>
#include<map>
#include<queue>
#include<algorithm>
using namespace std;
string dight[][]={"tret","jan","feb","mar","apr","may","jun","jly","aug","sep","oct","nov","dec",
"tret","tam","hel","maa","huh","tou","kes","hei","elo","syy","lok","mer","jou"};
int main(){
//freopen("D:\\INPUT.txt","r",stdin);
int n,num;
string s;
scanf("%d",&n);
while(n--){
cin>>s;
int i,j;
num=;
if(s[]>=''&&s[]<=''){
for(i=;i<s.length();i++){
num*=;
num+=s[i]-'';
}
if(num>){
cout<<dight[][num/];
num%=;
if(num){
cout<<" "<<dight[][num];
}
cout<<endl;
}
else{
cout<<dight[][num]<<endl;
}
}
else{
for(i=;i<;i++){
if(dight[][i]==s){
break;
}
}
if(i!=){
num+=*i;
if(getchar()==' '){
cin>>s;
for(i=;i<;i++){
if(dight[][i]==s){
break;
}
}
num+=i;
}
}
else{
for(i=;i<;i++){
if(dight[][i]==s){
break;
}
}
num+=i;
}
printf("%d\n",num);
}
}
return ;
}
pat1100. Mars Numbers (20)的更多相关文章
- PAT1100:Mars Numbers
1100. Mars Numbers (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue People o ...
- 1100. Mars Numbers (20)
People on Mars count their numbers with base 13: Zero on Earth is called "tret" on Mars. T ...
- PAT (Advanced Level) 1100. Mars Numbers (20)
简单题. #include<cstdio> #include<cstring> #include<cmath> #include<vector> #in ...
- PAT甲级题解-1100. Mars Numbers (20)-字符串处理
没什么好说的,注意字符串的处理,以及当数字是13的倍数时,只需高位叫法的单词.比如26,是“hel”,而不是“hel tret”. 代码: #include <iostream> #inc ...
- A1100 Mars Numbers (20 分)
一.技术总结 这一题可以使用map进行想打印存储,因为数据量不是很大,最后直接输出.但是还是觉得没有必要. 主要考虑两个问题,首先是数字转化为字符串,实质就是进制转化,但是有点不同,如果十位有数字,个 ...
- 【PAT甲级】1100 Mars Numbers (20 分)
题意: 输入一个正整数N(<100),接着输入N组数据每组包括一行字符串,将其翻译为另一个星球的数字. AAAAAccepted code: #define HAVE_STRUCT_TIMESP ...
- PAT甲级——1100 Mars Numbers (字符串操作、进制转换)
本文同步发布在CSDN:https://blog.csdn.net/weixin_44385565/article/details/90678474 1100 Mars Numbers (20 分) ...
- PAT_A1100#Mars Numbers
Source: PAT A1100 Mars Numbers (20 分) Description: People on Mars count their numbers with base 13: ...
- pat 1100 Mars Numbers(20 分)
1100 Mars Numbers(20 分) People on Mars count their numbers with base 13: Zero on Earth is called &qu ...
随机推荐
- 读paper笔记[Learning to rank]
读paper笔记[Learning to rank] by Jiawang 选读paper: [1] Ranking by calibrated AdaBoost, R. Busa-Fekete, B ...
- MVC下为什么要使用Areas
想研究一下这个Areas,在博客园知识库找到这篇文章,先全部搬过来吧,原文地址:http://kb.cnblogs.com/page/144561/ 为什么需要分离? 我们知道MVC项目各部分职责比较 ...
- 【C#】 创建、部署和调用WebService的简单示例
C# 创建.部署和调用WebService的简单示例 <div class="postBody"> <div id="cnblogs_post_body ...
- Installing the .NET Framework 3.5 on Windows 8, Windows 8.1 and Windows 10
Installing the .NET Framework 3.5 on Windows 8, Windows 8.1 and Windows 10 .NET Framework (current v ...
- 自定义Mybatis框架
项目结构: https://files-cdn.cnblogs.com/files/mkl7/ownMybatis.zip 1. 创建maven工程并引入坐标: <?xml versi ...
- Crontab 驱动 Scrapy 定时任务
做了个爬虫去定时抓自己发布在cnblogs更新的文章,考虑用corntab定时任务驱动 crontab 任务配置 crontab配置规则就不啰嗦了,网上很多介绍,规则很容易功能却很强大. 然后我发现只 ...
- 在Python中正确使用Unicode
正确处理文本,特别是正确处理Unicode.是个老生常谈的问题,有时甚至会难倒经验丰富的开发者.并不是因为这个问题很难,而是因为对软件中的文本,开发者没有正确理解一些关键概念及其表示方法.在Stack ...
- vee-validate使用教程
vee-validate使用教程 *本文适合有一定Vue2.0基础的同学参考,根据项目的实际情况来使用,关于Vue的使用不做多余解释.本人也是一边学习一边使用,如果错误之处敬请批评指出* 一.安装 n ...
- 3. mybatis # 与 $ 的区别
mybatis # 与 $ 的区别 1.# % 号必须写在test中 应用场景:模糊查询 配置文档mapper.xml <select id="selectBlogByTitle&qu ...
- Qt 学习之路 2(17):文件对话框
Home / Qt 学习之路 2 / Qt 学习之路 2(17):文件对话框 Qt 学习之路 2(17):文件对话框 豆子 2012年9月24日 Qt 学习之路 2 85条评论 在前面的章节中 ...