1100. Mars Numbers (20)

时间限制
400 ms
内存限制
65536 kB
代码长度限制
16000 B
判题程序
Standard
作者
CHEN, Yue

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)的更多相关文章

  1. PAT1100:Mars Numbers

    1100. Mars Numbers (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue People o ...

  2. 1100. Mars Numbers (20)

    People on Mars count their numbers with base 13: Zero on Earth is called "tret" on Mars. T ...

  3. PAT (Advanced Level) 1100. Mars Numbers (20)

    简单题. #include<cstdio> #include<cstring> #include<cmath> #include<vector> #in ...

  4. PAT甲级题解-1100. Mars Numbers (20)-字符串处理

    没什么好说的,注意字符串的处理,以及当数字是13的倍数时,只需高位叫法的单词.比如26,是“hel”,而不是“hel tret”. 代码: #include <iostream> #inc ...

  5. A1100 Mars Numbers (20 分)

    一.技术总结 这一题可以使用map进行想打印存储,因为数据量不是很大,最后直接输出.但是还是觉得没有必要. 主要考虑两个问题,首先是数字转化为字符串,实质就是进制转化,但是有点不同,如果十位有数字,个 ...

  6. 【PAT甲级】1100 Mars Numbers (20 分)

    题意: 输入一个正整数N(<100),接着输入N组数据每组包括一行字符串,将其翻译为另一个星球的数字. AAAAAccepted code: #define HAVE_STRUCT_TIMESP ...

  7. PAT甲级——1100 Mars Numbers (字符串操作、进制转换)

    本文同步发布在CSDN:https://blog.csdn.net/weixin_44385565/article/details/90678474 1100 Mars Numbers (20 分) ...

  8. PAT_A1100#Mars Numbers

    Source: PAT A1100 Mars Numbers (20 分) Description: People on Mars count their numbers with base 13: ...

  9. pat 1100 Mars Numbers(20 分)

    1100 Mars Numbers(20 分) People on Mars count their numbers with base 13: Zero on Earth is called &qu ...

随机推荐

  1. [转]关于截取字符串substr和substring两者的区别

    subString(start,stop) substr(start,length) substr和substring两个都是截取字符串的. 两者有相同点,如果只是写一个参数,两者的作用都是一样的:就 ...

  2. js 代码收集

    //获取image src路径 $(".userImg").click(function(){ var imgsrc = $(this).attr("src") ...

  3. MasterPage + UpdatePanel + FileUpload

    上传文件在母版页与Ajax的UpdatePanel的环境进行.由于在母版内使用Ajax,建议使用AjaxControlToolkit.dll组件,去微软官网下载后,并拉入BIN目录中. 然后去web. ...

  4. 正经学C#_变量与其数据类型:《c#入门经典》

    这一篇总结以下变量与其数据类型. 变量:在c#中指 某一个值或者数据存储在变量中,并且可以取出或者查看.变量不仅仅是一种,也有很多种,细分而言就是类型.泛指就是变量.如果是要是使用变量就要 声明变量, ...

  5. pch文件的创建与配置

    1.ios中pch文件的创建与配置 1.1 ios中pch文件的创建与配置 1.2 全局宏定义标志的配置 2.宏定义 这里放的主要是开发中常用的宏定义. /** 动态的字符串格式化宏 */ #defi ...

  6. C/C++ 遇到0xcccccccc访问冲突

    最近一直在纠结这个问题. 最近写代码,总是遇到这个问题,一旦遇到这个问题,以前好使的代码也就不好使了.很费解,上网搜集了下资料.... 这个0xcccccccc是DEBUG模式下,编译器为没有初始化的 ...

  7. ABAP开发常见任务

    在ABAP开发中 最主要的工作: 1 报表的开发 主要使用到数据库读取 ALV LIST等技术: 2 单据的打印 主要使用到数据库读取.SmartFirms.Form等技术: 3 数据的上载 主要使用 ...

  8. 7、OpenCV Python 高斯模糊

    __author__ = "WSX" import cv2 as cv import numpy as np #高斯模糊 基于权重(卷积) #高斯模糊 去燥效果很好 #高斯模糊 d ...

  9. php 过滤重复的数组

    首先数组分为一维数组和多维数组 1.一维数组 $a = array(a,b,c,d,a,b,e,f,g); array_unique($a) 就行了 2.二维数组 $a = array( array( ...

  10. 【SSO】单点登录系统

    一.单点登录系统介绍 对于一个开发项目来说,每个项目都必不可少要有登录的这个功能.但是随着项目的变大,变大,再变大.系统可能会被拆分成多个小系统,咱们就拿支付宝和淘宝来说,咱们在淘宝上购物,然后就可以 ...