2010年9月18日 星期六

ACM 300 - Maya Calendar

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

char hMonthStr[19][8] = {"pop", "no", "zip", "zotz",
"tzec", "xul", "yoxkin", "mol",
"chen", "yax", "zac", "ceh",
"mac", "kankin", "muan", "pax",
"koyab", "cumhu", "uayet"};
char tMonthStr[20][10] = {"imix", "ik", "akbal", "kan",
"chicchan", "cimi", "manik", "lamat",
"muluk", "ok", "chuen", "eb",
"ben", "ix", "mem", "cib",
"caban", "eznab", "canac", "ahau"};
char dStr[6], mStr[8];
int main()
{
int hDay, hMonth, hYear, tDay, tMonth, tYear;
int n, days, i;
scanf("%d", &n);
printf("%d\n", n);
while (n --)
{
char *d;
scanf("%s %s %d", dStr, mStr, &hYear);
d = strtok(dStr, ".");
sscanf(d, "%d", &hDay);
for (i = 0; i < 19; i ++)
{
if (strcmp(hMonthStr[i], mStr) == 0)
{ hMonth = i; break; }
}
days = hDay + hMonth * 20 + hYear * 365;
tYear = days / 260;
days %= 260;
tMonth = days % 20;
tDay = days % 13 + 1;

printf("%d %s %d\n", tDay, tMonthStr[tMonth], tYear);
}
return 0;
}

回目錄
回首頁

沒有留言 :

張貼留言

Related Posts Plugin for WordPress, Blogger...