清泉逐流

做着努力,等待幸福到来

Poj1008

作者:Eamonn 时间 : 2014-09-09 20:11 分类:C/C++

#include <string>
#include <iostream>
#include <map>
using namespace std;
#define HAAB_YEAR_DAYS  (20*18+1*5)
#define TZO_YEAR_DAYS   (13*20)
struct Haab_date{
    int day;
    int year;
};
struct Tzolkin_date{
    string day_str;
    int year;
};
void convert(Haab_date &haab, Tzolkin_date &tzo)
{
    static string tzo_map[20];
    tzo_map[0] = "imix";
    tzo_map[1] = "ik";
    tzo_map[2] = "akbal";
    tzo_map[3] = "kan";
    tzo_map[4] = "chicchan";
    tzo_map[5] = "cimi";
    tzo_map[6] = "manik";
    tzo_map[7] = "lamat";
    tzo_map[8] = "muluk";
    tzo_map[9] = "ok";
    tzo_map[10] = "chuen";
    tzo_map[11] = "eb";
    tzo_map[12] = "ben";
    tzo_map[13] = "ix";
    tzo_map[14] = "mem";
    tzo_map[15] = "cib";
    tzo_map[16] = "caban";
    tzo_map[17] = "eznab";
    tzo_map[18] = "canac";
    tzo_map[19] = "ahau";
       
    int days = HAAB_YEAR_DAYS*haab.year + haab.day;
    tzo.year = days / TZO_YEAR_DAYS;
    days -= tzo.year * TZO_YEAR_DAYS;
    char s[50];
    sprintf(s, "%d %s", (int)((days%13)+1), tzo_map[ days%20 ].c_str());
    tzo.day_str = s;
}
int main(int argc, char* argv[])
{
       
       
    map<string,int> haab_month_map;
    haab_month_map["pop"]=0;
    haab_month_map["no"]=1;
    haab_month_map["zip"]=2;
    haab_month_map["zotz"]=3;
    haab_month_map["tzec"]=4;
    haab_month_map["xul"]=5;
    haab_month_map["yoxkin"]=6;
    haab_month_map["mol"]=7;
    haab_month_map["chen"]=8;
    haab_month_map["yax"]=9;
    haab_month_map["zac"]=10;
    haab_month_map["ceh"]=11;
    haab_month_map["mac"]=12;
    haab_month_map["kankin"]=13;
    haab_month_map["muan"]=14;
    haab_month_map["pax"]=15;
    haab_month_map["koyab"]=16;
    haab_month_map["cumhu"]=17;
    haab_month_map["uayet"]=18;
       
           
    int n;
    cin >> n;
       
    cout << n << endl;
       
    for(int i=0; i!=n; i++){
        char yummy;
        int day;
        string month_str;
        Haab_date haab;
        Tzolkin_date tzo;
           
        cin >> day >> yummy >> month_str >> haab.year;
        int month = haab_month_map[month_str];
        haab.day = month*20+day;
           
        convert(haab,tzo);
           
        cout << tzo.day_str << " " << tzo.year << endl;
    }
       
       
    return 0;
}


转载注明: http://www.eamonning.com/note/view/35
» 笔记大类