zoukankan      html  css  js  c++  java
  • 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
    ",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
    ",mp[number].c_str());
            }
            else{     //说明是火星字
                printf("%d
    ",eto[str]);
                
            }
        }
        
        fclose(stdin);
        return 0;
    }
  • 相关阅读:
    计算数组的逆序对个数
    处理类型(typedef,uisng,auto,decltype)
    constexpr与常量表达式(c++11标准)
    const的限定
    void*类型的指针
    linux终端拖动鼠标总是产生ctrl+c
    Linux hrtimer分析(2)
    Linux hrtimer分析(一)
    Alarm(硬件时钟) init
    第十一章 Android 内核驱动——Alarm
  • 原文地址:https://www.cnblogs.com/phaLQ/p/10458314.html
Copyright © 2011-2022 走看看