首页 > 其他 > 详细

PAT_A1100

时间:2019-03-01 19:55:44      阅读:220      评论:0      收藏:0      [点我收藏+]

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;
}

 

PAT_A1100

原文:https://www.cnblogs.com/phaLQ/p/10458314.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!