POJ-1008 Maya Calendar

题目大意:两种历法的转换,注意转换后的历法类似于干支纪年法,月和日单独循环。

题目链接:http://poj.org/problem?id=1008

#include <stdio.h>
#include <iostream>
#include <string.h>
#include <math.h>
#include <algorithm>

using namespace std;

#define MAXN 10

char Haab[19][MAXN]={"pop", "no", "zip", "zotz", "tzec", "xul", "yoxkin",
"mol", "chen", "yax", "zac", "ceh", "mac", "kankin", "muan", "pax", "koyab", "cumhu","uayet"};

char Tzolkin[20][MAXN]={"imix", "ik", "akbal", "kan", "chicchan", "cimi", "manik", "lamat",
"muluk", "ok", "chuen", "eb", "ben", "ix", "mem", "cib", "caban", "eznab", "canac", "ahau"};

int getday(int d,char m[],int y)
{
    int day=0;
    day+=y*365;
    int mm;
    for(mm=0;mm<19;mm++)
    {
        if(strcmp(m,Haab[mm])==0)
            break;
    }
    day+=mm*20;
    day+=d;
    return day;
}

int main()
{
    int n;
    scanf("%d",&n);
    printf("%d\n",n);
    while(n--)
    {
        int day;
        char month[MAXN];
        int year;
        scanf("%d. %s %d",&day,month,&year);
        int num=getday(day,month,year);
        int y=num/260;
        int m=num%13+1;
        int d=num%20;
        printf("%d %s %d\n",m,Tzolkin[d],y);
    }
    return 0;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值