pat-B-1044. Mars numerals (20)

Source: Internet
Author: User

1044. Mars numerals (20) time limit of MS memory limit 65536 KB code length limit 8000 B award Program StandardAuthor Chen, Yue

The Martians are counted in 13 binary:

    • 0 of the Earth's people are called Tret by Martians.
    • Earth Human numbers 1 to 12 of the Martian texts are: Jan, Feb, Mar, Apr, May, June, Jly, Mar, Sep, Oct, Nov, Dec.
    • The Martians will carry the following 12 high-level numbers, respectively, called: Tam, Hel, Maa, huh, tou, Kes, Hei, ELO, Syy, Lok, Mer, Jou.

For example, the number of earth people "29" translated into The Martian text is "hel mar", while the Martian text "ELO" corresponds to the earth number "115". In order to facilitate communication, please write a program to achieve the Earth and Mars digital translation between.

Input format:

Enter the first line to give a positive integer n (<100), followed by n lines, each given a number in the [0, 169) Interval--Either the earth text, or the Martian text.

Output format:

For each line of the input, output the number of the translated language in one line.

Input Sample:
4295elo Novtam
Sample output:
Hel marmay11513

Detailed details please poke: http://blog.csdn.net/plank_root/article/details/51383098

1#include <iostream>2#include <cstdio>3#include <string>4 using namespacestd;5 intMain ()6 {7     intN;8Cin>>N;9     stringmess;Ten     stringThree=""; One     stringfire[ -]= {"Tret","Jan","Feb","Mar","Apr"," May","June","Jly"," the","Sep","Oct","Nov","Dec"}; A     stringjinzhi[ -]= {"Tam","Hel","Maa","Huh","tou","Kes","Hei","ELO","Syy","Lok","Mer","Jou"}; -     intLen,number=0; -GetChar ();//when using Getline, he will take the first cin>>n when the enter record, so that one less cycle so with GetChar () to capture the carriage return the      for(intI=0; i<n; i++) -     { - getline (cin,mess); -         if(mess[0]>='0'&&mess[0]<='9')//if it's a number +         { -              for(intj=0; J<mess.size (); J + +) +number=number*Ten+mess[j]-'0'; A             if(number< -)//Direct output of corresponding numbers atcout<<fire[number]<<Endl; -             Else  //if the value is greater than or equal to 13 and can be divisible by 13, the sample is not output 0 (Tret) -             { -                 if(number% -==0) cout<<jinzhi[number/ --1]<<Endl; -                 Elsecout<<jinzhi[number/ --1]<<" "<<fire[number% -]<<endl;//Otherwise, you have to enter -             } in         } -         Else //if it's a Martian text, to         { +              for(intk=0; K<mess.size (); k=k+4) -             { thethree=three+mess[k]+mess[k+1]+mess[k+2];//read every Martian text *                  for(intL=0; l< -; l++) $                 {Panax Notoginseng                     if(Three==fire[l])//If the Martian text is in the fire array, then it is the single digit in the 13 binary, just add the coordinates -number=number+l; the                     if(Three==jinzhi[l])//If you are in the Jinzhi array, multiply each time by +number=number+ (L +1)* -; A                 } theThree=""; +             } -cout<<number<<Endl; $         } $Number=0; -     } -     return 0; the}

pat-B-1044. Mars numerals (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.