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<stdio.h>
#include<string>
#include<iostream>
#include<string.h>
#include<sstream>
#include<vector>
#include<map>
using namespace std;
char firwei[][]={"tret","jan", "feb", "mar", "apr", "may", "jun", "jly", "aug", "sep", "oct", "nov", "dec"};
char secwei[][]={"tret","tam", "hel", "maa", "huh", "tou", "kes", "hei", "elo", "syy", "lok", "mer", "jou"};
map<string,int> mm1,mm2;
void toMar(int n)
{
vector<string> vv;
vv.push_back(firwei[n%]);
n = n / ;
if(n > )
{
vv.push_back(secwei[n]);
}
bool fir = ;
for(int i = vv.size() - ; i >= ;--i )
{
if(fir)
{
cout << vv[i];
fir = ;
}
else if( vv [i] != "tret" )cout << " " << vv[i] ;
}
cout << endl;
} int main()
{
int n;
for(int i = ;i < ;++i)
{
mm1[firwei[i]] = i;
}
for(int i = ;i < ;++i)
{
mm2[secwei[i]] = i;
}
scanf("%d",&n);
getchar();
string str;
for(int i = ;i < n;++i)
{
getline(cin,str);
if(str[]>='' && str[] <= '')
{
int num;
stringstream ss;
ss << str;
ss >> num;
toMar(num);
}
else
{
stringstream ss;
vector<string> svv;
string num;
int sum = ;
ss << str;
while(ss >> num)
{
svv.push_back(num);
}
if(svv.size() > )
{
sum = sum* + mm2[svv[]];
sum = sum* + mm1[svv[]];
}
else
{
sum = sum* + mm2[svv[]];
sum = sum* + mm1[svv[]];
}
printf("%d\n",sum);
}
}
return ;
}
1100. Mars Numbers (20)的更多相关文章
- 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 ...
- 【PAT甲级】1100 Mars Numbers (20 分)
题意: 输入一个正整数N(<100),接着输入N组数据每组包括一行字符串,将其翻译为另一个星球的数字. AAAAAccepted code: #define HAVE_STRUCT_TIMESP ...
- pat1100. Mars Numbers (20)
1100. Mars Numbers (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue People o ...
- PAT甲级——1100 Mars Numbers (字符串操作、进制转换)
本文同步发布在CSDN:https://blog.csdn.net/weixin_44385565/article/details/90678474 1100 Mars Numbers (20 分) ...
- pat 1100 Mars Numbers(20 分)
1100 Mars Numbers(20 分) People on Mars count their numbers with base 13: Zero on Earth is called &qu ...
- PAT 1100 Mars Numbers[难]
1100 Mars Numbers (20 分) People on Mars count their numbers with base 13: Zero on Earth is called &q ...
- 1100 Mars Numbers——PAT甲级真题
1100 Mars Numbers People on Mars count their numbers with base 13: Zero on Earth is called "tre ...
- 1100 Mars Numbers(20 分)
People on Mars count their numbers with base 13: Zero on Earth is called "tret" on Mars. T ...
随机推荐
- Linux下配置Java环境变量
今天开始简单的学习了一下在Linux下安装jdk 写下来总结一下以便后来的查找和复习 首先下载Linux版的jdk我这里使用的jdk1.7:http://download.oracle.com/otn ...
- VC++ UTF-8与GBK格式转换
// 注释:多字节包括GBK和UTF-8 int GBK2UTF8(char *szGbk,char *szUtf8,int Len) { // 先将多字节GBK(CP_ACP或ANSI)转换成宽字符 ...
- Hadoop YARN配置参数剖析—RM与NM相关参数
注意,配置这些参数前,应充分理解这几个参数的含义,以防止误配给集群带来的隐患.另外,这些参数均需要在yarn-site.xml中配置. 1. ResourceManager相关配置参数 (1) ...
- Warning: session_start() [function.session-start]: Cannot send session cookie解决办法
在很多时间使用了session就会出来如下提示了, Warning: session_start() [function.session-start]: Cannot send session coo ...
- jquery 导航固定的一个实例
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- oracle数据库执行脚本常用命令总结
1. 执行一个SQL脚本文件 代码如下 复制代码 sqlplus user/pass@servicename<file_name.sql或SQL>start file_names或SQL& ...
- 清除windows的EFS加密
所使用软件为aefsdr_setup_en,搜索名为advanced.efs.data.recovery 1. 创建需要加密的文件 2. 进行加密 ...
- 【百度地图API】JS版本的常见问题
1.请问如何将我的店铺标注在百度地图上?我是否可以做区域代理?在百度地图上标注是否免费? 答复: 这里只负责API的技术咨询,不解决任何地图标注问题.在百度地图上标注自己公司,即气泡标注业务.该业务已 ...
- ios警告:Category is implementing a method which will also be implemented by its primary class 引发的相关处理
今天在处理项目中相关警告的时候发现了很多问题,包括各种第三方库中的警告,以及各种乱七八糟的问题 先说说标题中的问题 Category is implementing a method which ...
- GPRS组网的几种方案【来自网络】
GPRS组网的几种方案:1) 方案一:中心采用ADSL等INTELNET公网连接,采用公网固定IP或者公网动态IP+DNS解析服务.此种方案向先INTERNET运营商申请ADSL等宽带业务. ...