The numbers 1 to 12 on Earth 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 Nlines 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.
#include<iostream> #include<string> #include<cctype> usingnamespace std; string ge[]={"tret","jan","feb","mar","apr","may","jun","jly","aug","sep","oct","nov","dec"}; string shi[]={"","tam","hel","maa","huh","tou","kes","hei","elo","syy","lok","mer","jou"}; intmain(){ int n; cin>>n; getchar(); while(n--){ string str; getline(cin,str); if (isdigit(str[0])) { int num = 0; for (int i = 0; i < str.length(); ++i) { num = num*10+str[i]-'0'; } if (num<13) { cout<<ge[num]<<endl; }elseif(num%13==0){ cout<<shi[num/13]<<endl; }else{ cout<<shi[num/13]<<" "<<ge[num%13]<<endl; } }else{ if (str.find(" ")==string::npos) { int flag = 0; for (int i = 0; i < 13; ++i) { if (str==ge[i]) { flag = 1; cout<<i<<endl; break; } } if (flag == 0) { for (int i = 0; i < 13; ++i) { if (str==shi[i]) { cout<<i*13<<endl; } } } }else{ string s1,s2; int i = 0; for (; str[i] != ' '; ++i) { s1+=str[i]; } i++; for (; i < str.length(); ++i) { s2+=str[i]; } int ans = 0; for (int i = 0; i < 13; ++i) { if (s1==shi[i]) { ans+=i*13; break; } } for (int i = 0; i < 13; ++i) { if (s2==ge[i]) { ans+=i; } } cout<<ans<<endl;