【PAT】B1044 火星数字(20 分)

/*
火星文有两位,第二位为0不输出

 */
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<ctype.h>

using namespace std;
char arr[20]={0};
char data[13][2][5]={
{"tret","tret"},
{"jan","tam"},
{"feb","hel"},
{"mar","maa"},
{"apr","huh"},
{"may","tou"},
{"jun","kes"},
{"jly","hei"},
{"aug","elo"},
{"sep","syy"},
{"oct","lok"},
{"nov","mer"},
{"dec","jou"}
};
void prr(char *str){
    if(str[3]==‘t‘&&str[0]==‘t‘&&str[1]==‘r‘&&str[2]==‘e‘){
        printf("0");return;
    }
    if(islower(str[0])){//输入为火星文
        int high=0,low=0;
        for(int i=0;i<13;i++){
            if(data[i][1][0]==str[0]&&data[i][1][1]==str[1]&&data[i][1][2]==str[2])//前边的字符只可能是高位
                high+=i*13;
            if(data[i][0][0]==str[0]&&data[i][0][1]==str[1]&&data[i][0][2]==str[2])//后边的字符不确定
                low+=i;
            if(data[i][0][0]==str[4]&&data[i][0][1]==str[5]&&data[i][0][2]==str[6]&&str[3]!=‘\0‘)
                low+=i;
        }
        printf("%d",low+high);
    }
    else{//输入为数字
        int temp;
        sscanf(str,"%d",&temp);
        if(temp<13){
            printf("%s",&data[temp][0]);
        }
        else{
            printf("%s",&data[temp/13][1]);
            if(temp%13!=0)
            printf(" %s",&data[temp%13][0]);
        }
    }
}
int main(){
    int N;scanf("%d",&N);
    for(int i=0;i<N;i++){
        scanf(" %[^\n]",arr);
        if(i!=0) printf("\n");
        prr(arr);
    }
    return  0;
}

原文地址:https://www.cnblogs.com/hebust/p/9498019.html

时间: 2024-11-07 09:23:07

【PAT】B1044 火星数字(20 分)的相关文章

PTA乙级 (*1044 火星数字 (20分))

1044 火星数字 (20分) https://pintia.cn/problem-sets/994805260223102976/problems/994805279328157696 #include <iostream> #include <cstdio> #include <cstring> #include <string> #include <cmath> #include <algorithm> using namesp

PAT 1044. 火星数字(20)

火星人是以13进制计数的: 地球人的0被火星人称为tret. 地球人数字1到12的火星文分别为:jan, feb, mar, apr, may, jun, jly, aug, sep, oct, nov, dec. 火星人将进位以后的12个高位数字分别称为:tam, hel, maa, huh, tou, kes, hei, elo, syy, lok, mer, jou. 例如地球人的数字"29"翻译成火星文就是"hel mar":而火星文"elo no

1044. 火星数字(20)

1044. 火星数字(20) 火星人是以13进制计数的: 地球人的0被火星人称为tret. 地球人数字1到12的火星文分别为:jan, feb, mar, apr, may, jun, jly, aug, sep, oct, nov, dec. 火星人将进位以后的12个高位数字分别称为:tam, hel, maa, huh, tou, kes, hei, elo, syy, lok, mer, jou. 例如地球人的数字"29"翻译成火星文就是"hel mar":而

PAT-乙级-1044. 火星数字(20)

1044. 火星数字(20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 CHEN, Yue 火星人是以13进制计数的: 地球人的0被火星人称为tret. 地球人数字1到12的火星文分别为:jan, feb, mar, apr, may, jun, jly, aug, sep, oct, nov, dec. 火星人将进位以后的12个高位数字分别称为:tam, hel, maa, huh, tou, kes, hei, elo,

PAT——1044. 火星数字

火星人是以13进制计数的: 地球人的0被火星人称为tret. 地球人数字1到12的火星文分别为:jan, feb, mar, apr, may, jun, jly, aug, sep, oct, nov, dec. 火星人将进位以后的12个高位数字分别称为:tam, hel, maa, huh, tou, kes, hei, elo, syy, lok, mer, jou. 例如地球人的数字"29"翻译成火星文就是"hel mar":而火星文"elo no

pat 1035 Password(20 分)

1035 Password(20 分) To prepare for PAT, the judge sometimes has to generate random passwords for the users. The problem is that there are always some confusing passwords since it is hard to distinguish 1 (one) from l (L in lowercase), or 0 (zero) fro

pat 1077 Kuchiguse(20 分) (字典树)

1077 Kuchiguse(20 分) The Japanese language is notorious for its sentence ending particles. Personal preference of such particles can be considered as a reflection of the speaker's personality. Such a preference is called "Kuchiguse" and is often

[PTA] PAT(A) 1008 Elevator (20 分)

目录 Problem Description Input Output Sample Sample Input Sample Output Solution Analysis Code Problem portal: 1008 Elevator (20 分) Description  The highest building in our city has only one elevator. A request list is made up with $N$ positive numbers

PAT乙级1088-----三人行 (20分)

1088 三人行 (20分) 输入样例 1: 48 3 7 输出样例 1: 48 Ping Cong Gai 输入样例 2: 48 11 6 输出样例 2: No Solution 思路:1.丙的能力值有可能是小数因此要用double 首次通过代码: 1 #include<stdio.h> 2 #include<stdlib.h> 3 #include<math.h> 4 5 6 7 int main(){ 8 int m,x,y; 9 int flag=1; 10 s