玛雅历的换算:先计算出天数,然后换算成Tzolkin表示法,注意haab表示第19个月时只有0-4,还有注意单词表拼错了,我拼错了白WA了。
#include<stdio.h>
#include<string.h>
typedef struct h{
int h_year;
int h_day;
char h_month[10];
}Haab;
typedef struct t{
int t_year;
int t_month;
char t_day[10];
}Tzolkin;
const char haab_map[20][10]={"pop","no","zip","zotz","tzec","xul","yoxkin","mol","chen","yax","zac","ceh","mac","kankin","muan","pax","koyab","cumhu","uayet"};
const char tzolkin_map[21][10]={"imix","ik","akbal","kan","chicchan","cimi","manik","lamat","muluk","ok","chuen","eb","ben","ix","mem","cib","caban","eznab","canac","ahau"};
int getTotalDay(int day,char * month,int year){
int sum=0;
int i;
sum=year*365+day;
for(i=0;i<19;i++){
if(strcmp(month,haab_map[i])==0){
sum+=20*i;
break;
}
}
return sum;
}
void main(){
int number,i=0,total_day;
scanf("%d",&number);
printf("%d\n",number);
Haab h_date;
Tzolkin t_date;
while(i<number){
scanf("%d. %s %d",&h_date.h_day,h_date.h_month,&h_date.h_year);
total_day=getTotalDay(h_date.h_day,h_date.h_month,h_date.h_year);
t_date.t_year = total_day/260;
t_date.t_month = (total_day%260)%13+1;
strcpy(t_date.t_day,tzolkin_map[(total_day%260)%20]);
printf("%d %s %d\n",t_date.t_month,t_date.t_day,t_date.t_year);
i++;
}
}
微信扫一扫,订阅我的博客动态^_^