> Analysis
>> First calculate the total number of days, then the conversion can be > Note>> Don't copy the wrong string>> output Number firstthe >> function "Strnlen" will cause GCC to compile but > attached Code
1#include"stdio.h"2#include"stdlib.h"3 4 Const Charhaabmonstr[ +][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 Ten Const Chartzolkindaystr[ -][Ten] = One{"Imix","ik","Akbal","kan","Chicchan", A "Cimi","Manik","Lamat","Muluk","OK", - "Chuen","EB","Ben","IX","Mem", - "CIB","Caban","Eznab","Canac","Ahau" } ; the - intHaabmon2int (Char*Mon) - { - inti =0 ; + - for(i =0; I < +; i++) + { A if(MEMCMP (Haabmonstr[i], Mon, strlen (mon)) = =0) at returni; - } - - return-1 ; - } - in intMainvoid) - { to intn =0 ; + intHaabday =0 ; - Charhaabmon[8] = {0} ; the intHaabyear =0 ; * intTzolkinnum =0 ; $ intTzolkinday =0 ;Panax Notoginseng intTzolkinyear =0 ; - intDays =0 ; the +scanf"%d", &n); Aprintf"%d\r\n", n); the + while(n--) - { $scanf"%d.%s%d", &haabday, Haabmon, &haabyear); $ -Days = Haabyear *365+ haabmon2int (Haabmon) * -+Haabday; - theTzolkinyear = days/260 ; -Tzolkinnum = days%260% - ;WuyiTzolkinday = days%260% - ; the -printf"%d%s%d\r\n", Tzolkinnum +1, Wu Tzolkindaystr[tzolkinday], tzolkinyear); - } About $ return 0 ; -}
Poj-1008:maya Calendar detailed 1: Direct computing method