标签:
> 分析
1 #include "stdio.h" 2 #include "stdlib.h" 3 4 const char haabMonStr[19][8] = 5 { "pop", "no", "zip", "zotz", "tzec", 6 "xul", "yoxkin", "mol", "chen", "yax", 7 "zac", "ceh", "mac", "kankin", "muan", 8 "pax", "koyab", "cumhu", "uayet" } ; 9 10 const char tzolkinDayStr[20][10] = 11 { "imix", "ik", "akbal", "kan", "chicchan", 12 "cimi", "manik", "lamat", "muluk", "ok", 13 "chuen", "eb", "ben", "ix", "mem", 14 "cib", "caban", "eznab", "canac", "ahau" } ; 15 16 int haabMon2Int(char *mon) 17 { 18 int i = 0 ; 19 20 for(i = 0; i < 19; i++) 21 { 22 if(memcmp(haabMonStr[i], mon, strlen(mon)) == 0) 23 return i ; 24 } 25 26 return -1 ; 27 } 28 29 int main(void) 30 { 31 int n = 0 ; 32 int haabDay = 0 ; 33 char haabMon[8] = {0} ; 34 int haabYear = 0 ; 35 int tzolkinNum = 0 ; 36 int tzolkinDay = 0 ; 37 int tzolkinYear = 0 ; 38 int days = 0 ; 39 40 scanf("%d", &n) ; 41 printf("%d\r\n", n) ; 42 43 while(n--) 44 { 45 scanf("%d. %s %d", &haabDay, haabMon, &haabYear) ; 46 47 days = haabYear * 365 + haabMon2Int(haabMon) * 20 + haabDay ; 48 49 tzolkinYear = days / 260 ; 50 tzolkinNum = days % 260 % 13 ; 51 tzolkinDay = days % 260 % 20 ; 52 53 printf("%d %s %d\r\n", tzolkinNum + 1, 54 tzolkinDayStr[tzolkinDay], tzolkinYear) ; 55 } 56 57 return 0 ; 58 }
POJ-1008: Maya Calendar 详解1: 直接计算法
标签:
原文地址:http://www.cnblogs.com/codesworld/p/4715355.html