PAT_A1100

AC代码:

#include <iostream>
#include <cstdio>
#include <map>
#include <string>
#include <vector>
using namespace std;


enum v1{jan, feb, mar, apr, may, jun, jly, aug, sep, oct, nov, dec};
enum v2{tam, hel, maa, huh, tou, kes, hei, elo, syy, lok, mer, jou};

map<int, string> mp;
map<string ,int> eto;

void hanshu(void)
{
    int a,b;
    string s1[13]={"tret","jan","feb","mar","apr","may","jun",
                            "jly","aug","sep","oct","nov","dec"};
    string s2[13]={"tret","tam","hel","maa","huh","tou","kes",
                            "hei","elo","syy","lok","mer","jou"};
    
    //存在0的 
    for(int i=0;i<13;i++){
        mp[i]=s1[i];
        eto[s1[i]]=i;    
    }
    for(int i=1;i<13;i++){
        mp[13*i]=s2[i];
        eto[s2[i]]=i*13; 
    }
    
    //不存在0的
    for(int i=1;i<13;i++){
        for(int j=1;j<13;j++){
            mp[i*13+j]=s2[i]+" "+s1[j];
            eto[mp[i*13+j]]=i*13+j;
        }
    } 
}

int main(void)
{
    hanshu();
    freopen("in.txt","r",stdin);
    int n;
    scanf("%d",&n);
    char m=getchar();
    //char m=getchar();
    for(int i=1;i<=n;i++){
        string str;
        getline(cin, str);
//        printf("%s\n",str.c_str());
        if(str[0] >= '0' && str[0] <= '9'){     //说明是数字 
            int number=0;
            for(int j = 0; j < str.size(); j++){
                number = number * 10 + (str[j] - '0');
            }
            printf("%s\n",mp[number].c_str());
        }
        else{     //说明是火星字
            printf("%d\n",eto[str]);
            
        }
    }
    
    fclose(stdin);
    return 0;
}

 

posted @ 2019-03-01 19:15  pha创噬  阅读(189)  评论(0编辑  收藏  举报