PAT 1044. Mars numerals (20)

Source: Internet
Author: User
Tags strtok

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
It is important to note that 10 digits have a digit and the digit is zero, only 10 digits are output.
1#include <stdio.h>2#include <string.h>3#include <stdlib.h>4#include <ctype.h>5#include <math.h>6 7 intMain () {8     Charlow[ -][5]={"Tret","Jan","Feb","Mar","Apr"," May","June","Jly"," the","Sep","Oct","Nov","Dec"};9     Charup[ -][5]={" ","Tam","Hel","Maa","Huh","tou","Kes","Hei","ELO","Syy","Lok","Mer","Jou"};Ten     Chartemp[Ten]; One     intTemp1; A     intN; -scanf"%d",&n); - GetChar (); the      for(intI=0; i<n;i++){ - gets (temp); -         if(temp[0]>='0'&&temp[0]<='9'){ -             intA =atoi (temp); +             if(A -!=0){ -                 if(a% -){ +printf"%s", up[a/ -]); Aprintf"%s\n", low[a% -]); at                 } -                 Else -printf"%s\n", up[a/ -]); -             } -             Else     -printf"%s\n", low[a% -]); in         }     -         Else{ toTemp1 =0; +             Char*result = Strtok (temp," ");  -              for(intj=0;j< -; j + +){ the                 if(strcmp (up[j],result) = =0){ *Temp1 = temp1+j* -; $                 }Panax Notoginseng             } -              for(intj=0;j< -; j + +){ the                 if(strcmp (low[j],result) = =0){ +Temp1 = temp1+J; A                 } the             } +result = Strtok (NULL," "); -             if(result!=NULL) { $                  for(intj=0;j< -; j + +){ $                     if(strcmp (low[j],result) = =0){ -Temp1 = temp1+J; -                     } the                 } -             }Wuyiprintf"%d\n", TEMP1); the         } -          Wu     }  -}

PAT 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.