Photolog

Through the Looking-Glass
2010-10-12: Through the Looking-Glass
My radio speaks is binary!
2010-10-10: My radio speaks is binary!
Gigaminx: (present for my birthday)
2010-09-16: Gigaminx: (present for my birthday)
Trini on bike
2010-09-05: Trini on bike
Valporquero
2010-08-28: Valporquero
My new bike!
2010-08-22: My new bike!
Mario and Ana's wedding
2010-08-13: Mario and Ana's wedding
Canyoning in Guara
2010-08-07: Canyoning in Guara
Trini and Mari in Marbella
2010-08-05: Trini and Mari in Marbella
Trini and Chelo in Tabarca
2010-08-03: Trini and Chelo in Tabarca
Valid XHTML 1.1
Log in
Back to list of problems

Maya Calendar

300.c

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

char *names1[] = {
	"pop", "no", "zip", "zotz", "tzec", "xul", "yoxkin", "mol", "chen",
	"yax", "zac", "ceh", "mac", "kankin", "muan", "pax", "koyab", "cumhu", "uayet"
};

char *names2[] = {
	"imix", "ik", "akbal", "kan", "chicchan", "cimi", "manik", "lamat",
	"muluk", "ok", "chuen", "eb", "ben", "ix", "mem", "cib", "caban",
	"eznab", "canac", "ahau"
};

int main(void)
{
	int i,j,num;
	int day, year;
	int epoch;
	char mon[1024];
	int mon2;

	scanf("%d", &num);
	printf("%d\n", num);

	for(i=0; i<num; i++) {
		scanf("%d. %s %d", &day, mon, &year);
		mon2=-1;
		for(j=0; j<19; j++) {
			if (!strcmp(mon, names1[j])) {
				mon2=j;
				break;
			}
		}
		if (mon2==-1) {
			abort();
		}
		epoch = year*365 + 20*mon2 + day;
		printf("%d %s %d\n", ((epoch%260)%13)+1, names2[(epoch%260)%20], epoch/260);
	}
	exit(0);
}