/*************************
题意:
13进制转话题
************************/
/***********************
解题思路:
注意以下几个坑即可
1. 0 -> zero
2. 13 -> tam (不带zero)
*************************/
/***********************
笔记:
每当你用i = s.substr()时
后面一定不要用i来做循环变量
*********************/
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<queue>
#include<stdlib.h>
#include<algorithm>
#include<string.h>
#include<stack>
#include<map>
#include<set>
#include<unordered_map>
using namespace std;
#define M 105
#define INF 0x7ffffff
string low[13]={"tret","jan","feb", "mar", "apr", "may", "jun", "jly", "aug", "sep", "oct", "nov", "dec"};
string high[13]={"","tam", "hel", "maa", "huh", "tou", "kes", "hei", "elo", "syy", "lok", "mer", "jou"};
int main(){
int n, i;
int nh,nl;
string s,s1,s2;
cin>>n;
int num;
getchar();
while(n--){
getline(cin, s);
if(s[0]>='0' && s[0]<='9'){
num = atoi(s.c_str());
nl = num%13;
nh = num/13;
if(nh != 0)
cout<<high[nh];
if(nl != 0){
if(nh != 0)
cout<<" ";
cout<<low[nl];
}
else if(nh == 0)
cout<<low[0];
cout<<endl;
}else{
i = s.find(" ");
num = 0;
if(i != -1){
s1 = s.substr(0,i);
for(int j = 1;j<=12;j++){
if(s1 == high[j]){
num += 13*j;
break;
}
}
s2 = s.substr(i+1);
}
else s2 = s;
for(i = 0;i <= 12;i++){
if(s2 == low[i]){
num += i;
break;
}
}
if(i==13){
for(i = 1;i<=12;i++)
if(s2 == high[i]){
num += 13*i;
break;
}
}
printf("%d\n",num);
}
}
return 0;
}
PAT 1100. Mars Numbers (20) 13进制转化
最新推荐文章于 2021-03-08 20:45:35 发布