poj 1008 Maya Calendar

#include <iostream>
#include
<string>
using namespace std;
char Haab_months[19][10]={
"pop","no","zip","zotz","tzec","xul","yoxkin","mol","chen","yax","zac","ceh","mac","kankin","muan","pax","koyab","cumhu","uayet"};
char Tzolkin_days[20][10]={
"imix","ik","akbal","kan","chicchan","cimi","manik","lamat","muluk","ok","chuen","eb","ben","ix","mem","cib","caban","eznab","canac","ahau"};
int main()
{
int t,total_day,i;
scanf(
"%d",&t);
printf(
"%d\n",t);
int Haab_day,Haab_year;
char Haab_month[10];
while(t--)
{
scanf(
"%d.%s%d",&Haab_day,Haab_month,&Haab_year);
total_day
=365*Haab_year+Haab_day;
//本来是total_day=..+Haab_day+1;此处将总日期减去1,如果原来日期是260天,年:total_day/260=1,但输出要求是0,而259/260=0,满足要求
//Tzolkin_days[total_day%20],如果原来是20,要输出的是Tzolkin_days[19]那么total_day%20=0,现在(20-1)%20=19,满足要求
for(i=0;;i++)
if(strcmp(Haab_month,Haab_months[i])==0)
break;
total_day
+=20*i;
printf(
"%d %s %d\n",total_day%13+1,Tzolkin_days[total_day%20],total_day/260);
}
return 0;
}

  

posted on 2011-07-20 22:27  sysu_mjc  阅读(120)  评论(0编辑  收藏  举报

导航