C++源代码:
// Maya Calendar
// 2017.03.17 by wyj
#include
#include
#include
using namespace std;
int main()
{
struct Haab
{
char day[5];
string month;
int year;
};
struct Tzolkin
{
int month;
string day;
int year;
};
int n, count[1000];
int mon1, day1, day2;
int i, j, k;
struct Haab ha[1000];
struct Tzolkin tz[1000];
string ha_mon[19] = { "pop", "no", "zip", "zotz", "tzec",
"xul", "yoxkin", "mol", "chen", "yax",
"zac", "ceh", "mac", "kankin", "muan",
"pax", "koyab", "cumhu","uayet" };
string tz_day[20] = { "imix", "ik", "akbal", "kan", "chicchan",
"cimi", "manik", "lamat", "muluk", "ok",
"chuen", "eb", "ben", "ix", "mem",
"cib", "caban", "eznab", "canac", "ahau" };
cin >> n;
for (i = 0;i < n;i++)
{
//scanf_s("%d%s%d", &ha[i].day, &ha[i].month, &ha[i].year);
cin >> ha[i].day>> ha[i].month >> ha[i].year;
//for (k = 0, day1 = 0; (ha[i].day[k] != '.') & (ha[i].day[k]!='\0'); k++)
for (k = 0, day1 = 0; ha[i].day[k] != '.'; k++)
day1 = day1*10 + ha[i].day[k] - '0';
for (j = 0,mon1 = 0;j < 19;j++)
if (ha[i].month == ha_mon[j])
mon1 = j;
count[i] = 365 * ha[i].year + 20 * mon1 + day1;
//cout << count[i] << endl;
}
printf("%d\n", n);
for (i = 0,day2 = 0;i < n; i++)
{
tz[i].year = count[i] / 260;
tz[i].month = count[i] % 13 + 1;
day2 = count[i] % 260 % 20;
tz[i].day = tz_day[day2];
cout << tz[i].month << ' ' << tz[i].day << ' ' << tz[i].year <