码迷,mamicode.com
首页 > 其他好文 > 详细

【poj1008】Maya Calendar

时间:2016-06-19 22:59:24      阅读:144      评论:0      收藏:0      [点我收藏+]

标签:

模拟,先算出天数,再转化成另一个历。

#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
char name[21][10] = {"0","imix","ik","akbal","kan","chicchan","cimi","manik","lamat","muluk","ok","chuen","eb","ben","ix","mem","cib","caban","eznab","canac","ahau"};
int getmonth(char *a)
{
    int ASCII = 0,l = strlen(a);
    for (int i=0;i<l;i++)
        ASCII += a[i];
    switch(ASCII)
    {
        case 335:return 1;
        case 221:return 2;
        case 339:return 3;
        case 471:return 4;
        case 438:return 5;
        case 345:return 6;
        case 674:return 7;
        case 328:return 8;
        case 414:return 9;
        case 338:return 10;
        case 318:return 11;
        case 304:return 12;
        case 305:return 13;
        case 636:return 14;
        case 433:return 15;
        case 329:return 16;
        case 534:return 17;
        case 546:return 18;
        case 552:return 19;
    }
}
int getday(int day,int month,int year)
{
    int sumday = 0;
    for (int i=0;i<year;i++)
        sumday += 365;
    for (int i=1;i<month;i++)
        sumday += 20;
    return sumday+day;
}
int main()
{
    int T,day,year,sumday = 0;
    char month[10];
    char doc;
    cin>>T;
    cout<<T<<endl;
    while (T--)
    {
        cin>>day>>doc>>month>>year;
        sumday = getday(day,getmonth(month),year);
        cout<<sumday%13+1<< <<name[sumday%20+1]<< <<sumday/260<<endl;
    }
}

 

【poj1008】Maya Calendar

标签:

原文地址:http://www.cnblogs.com/liumengyue/p/5598848.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!