1100. Mars Numbers (20)

Source: Internet
Author: User

People on Mars count their numbers with base 13:

    • Zero on Earth was called "Tret" on Mars.
    • The numbers 1 to earch are called "Jan, Feb, Mar, Apr, May, June, Jly, Mar, Sep, Oct, Nov, Dec" on Mars, respectively.
    • For the next higher digit, Mars people name the numbers as "Tam, Hel, Maa, huh, tou, Kes, Hei, ELO, Syy, Lok, Mer, Jou" , respectively.

For examples, the number in Earth is called ' hel mar ' on Mars; and "Elo Nov" on the Mars corresponds to the Earth. In order to help communication between people from these-planets, you is supposed to write a program for mutual trans Lation between Earth and Mars number systems.

Input Specification:

Each input file contains the 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 the Earth number, or that of Mars.

Output Specification:

For each number, print in a line the corresponding number in the other language.

Sample Input:

4295elo Novtam

Sample Output:

Hel marmay11513
1#include <stdio.h>2#include <string>3#include <iostream>4#include <string.h>5#include <sstream>6#include <vector>7#include <map>8 using namespacestd;9 Charfirwei[ -][5]={"Tret","Jan","Feb","Mar","Apr"," May","June","Jly"," the","Sep","Oct","Nov","Dec"};Ten Charsecwei[ -][5]={"Tret","Tam","Hel","Maa","Huh","tou","Kes","Hei","ELO","Syy","Lok","Mer","Jou"}; Onemap<string,int>mm1,mm2; A voidToMar (intN) - { -vector<string>VV; theVv.push_back (firwei[n% -]); -n = n/ -; -     if(N >0) -     { + Vv.push_back (Secwei[n]); -     } +     BOOLFIR =1; A      for(inti = vv.size ()-1; I >=0;--i) at     { -         if(FIR) -         { -cout <<Vv[i]; -FIR =0; -         } in         Else if(vv [i]! ="Tret") cout <<" "<<Vv[i]; -     } tocout <<Endl; + } -  the intMain () * { $     intN;Panax Notoginseng      for(inti =0; I < -;++i) -     { theMm1[firwei[i]] =i; +     } A      for(inti =0; I < -;++i) the     { +Mm2[secwei[i]] =i; -     } $scanf"%d",&n); $ GetChar (); -     stringstr; -      for(inti =0; I < n;++i) the     { - getline (CIN,STR);Wuyi         if(str[0]>='0'&& str[0] <='9') the         { -             intnum; Wu StringStream SS; -SS <<str; AboutSS >>num; $ ToMar (num); -         } -         Else -         { A StringStream SS; +vector<string>Svv; the             stringnum; -             intsum =0; $SS <<str; the              while(SS >>num) the             { the svv.push_back (num); the             } -             if(Svv.size () >1) in             { thesum = sum* -+ mm2[svv[0]]; thesum = sum* -+ mm1[svv[1]]; About             } the             Else the             { thesum = sum* -+ mm2[svv[0]]; +sum = sum* -+ mm1[svv[0]]; -             } theprintf"%d\n", sum);Bayi         } the     } the     return 0; -}

1100. Mars Numbers (20)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.