思路是将输入的Haab日历转化为对0.pop 0的天数,按照对应的天数算出Tzolkin历
#include<stdio.h> #include<string.h> // 20*18+5 char Haab[19][10] = {"pop", "no", "zip", "zotz", "tzec", "xul", "yoxkin", "mol", "chen", "yax", "zac", "ceh", "mac", "kankin", "muan", "pax", "koyab", "cumhu","uayet"}; //13*20 char Tzolkin[][10] = {"imix", "ik", "akbal", "kan", "chicchan", "cimi", "manik", "lamat", "muluk", "ok", "chuen", "eb", "ben", "ix", "mem", "cib", "caban", "eznab", "canac", "ahau"}; //返回对应月份的数组下标 int haab_Month(char *ch) { int i; for(i = 0; i <20; i++) { if(strcmp(Haab[i],ch) == 0) return i; } return -1; } int main() { int n; scanf("%d", &n); int h_Day, h_Year, t_Year, t_Day; char c; char h_Month[10], t_Month[10]; //days 为输入时间到0.pop 0的天数 int days; for(int i = 0; i < n; i++) { days = 0; scanf("%d %c %s %d", &h_Day, &c, h_Month, &h_Year); for(int j = 0; j < haab_Month(h_Month); j++) { days += 20; //含有最后一个月只加5天(20-15) if(j == 18) days -= 15; } days += (h_Day+h_Year*365+1); //Tzolkin历的年 t_Year = days/260; days -= t_Year*260; //Tzolkin历的日(第一位数字)通过Tzolkin数组获得第二位 t_Day = days%13; printf("%d %s %d\n",t_Day, Tzolkin[days%20-1], t_Year); } return 0; }
时间: 2024-10-12 11:08:06