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)