Mayan calendar

Description

Last weekend, a professor MA Ya made a major discovery of the ancient Maya. From an old knotted (Maya tool for memos), the professor found that the Maya used a calendar year, called Haab of 365 days. The Haab calendar has 19 months, 18 months beginning, 20 days a month, the month names are pop, no, zip, zotz, tzec, xul, yoxkin, mol, chen, yax, zac, ceh, mac, kankin, muan, pax, koyab, cumhu. These date of the month indicated by 0-19. Haab was last month named uayet, it is only five days, with a 0-4 representation. The Maya believed that this minimum date is unlucky month, this month the court is not hearing that people do not engage in trading, not even sweep the house floor.

For religious reasons, the Maya used another calendar, this calendar is known as the middle-aged Tzolkin (holly), the year is divided into 13 distinct periods, each period of 20 days, each day with a digital and in the form of a combination of words represented. Numbers used are 1 to 13, a word used in a total of 20, they are: imix, ik, akbal, kan, chicchan, cimi, manik, lamat, muluk, ok, chuen, eb, ben, ix, mem, cib , caban, eznab, canac, ahau. Note: In every day has an unambiguous description of, for example, at the beginning of the year, the date is described as follows: 1 imix, 2 ik, 3 akbal, 4 kan, 5 chicchan, 6 cimi, 7 manik, 8 lamat, 9 muluk, 10 ok, 11 chuen, 12 eb, 13 ben, 1 ix, 2 mem, 3 cib, 4 caban, 5 eznab, 6 canac, 7 ahau,, 8 imix, 9 ik, 10 akbal ...... That numbers and words independently recycled.

Haab and Tzolkin numbers are used in the annual 0,1, ...... represents the number 0 represents the beginning of the world. So the first day is expressed as:
Haab: 0. POP 0
Tzolkin: IMIX 1 0
Help professor MA Ya and write a program to convert the Haab calendar Tzolkin calendar.
Input

Haab calendar data is represented by the following way:
Date Number of month

The first line indicates the amount of data input to the conversion of Haab date. Below each row represents a date, the number of years less than 5000.
Output

Tzolkin calendar data is represented by the following way:
the Days Days of Number Name

The first line indicates the number of the output date. Each row represents a following Tzolkin calendar date corresponding to the input.
Sample Input

3
10. zac 0
0. pop 0
10. zac 1995
Sample Output

3
3 chuen 0
1 imix 0
9 cimi 2801

#include <iostream>
#include<string.h>
#include<math.h>

using namespace std;

class Haab {
public:
	char Months[19][10]={ "pop", "no", "zip", "zotz", "tzec", "xul", "yoxkin", "mol", "chen",
		"yax", "zac", "ceh", "mac", "kankin", "muan", "pax", "koyab", "cumhu","uayet" };
	char *day=new char[10];
	char* month=new char[10];
	int year;

	void input(){
		cin >> day >> month >> year;
	}

	int output() {
		int sum = 0;
		sum += year * 365;
		int i = 0;

		for (; i < 19; i++)
			if (!strcmp(month,Months[i])) break;

		sum += 20 * i;

		int j = -1;
		int f = 0;
		char *temp=new char[10];

		for (int i = 0; i < 10; i++)
		{
			if (day[i] == '.') break;
			temp[i] = day[i];
			j++;
		}

		while (j >= 0) {
			sum = sum + pow(10.0, f)*(int)(temp[j] - '0');
			f++;
			j--;
		}
		return sum;
	}

};
class Tzolkin {
public:
	char Months[20][10] = { "imix", "ik", "akbal", "kan", "chicchan", "cimi", "manik", "lamat", "muluk", "ok", "chuen", "eb", "ben", "ix", "mem", "cib","caban", "eznab", "canac", "ahau" };
	int day;
	char*month = new char[10];
	int year;

	Tzolkin(int days) {
		year = days / 260;
		days %= 260;
		int j = 0;
		day = days % 13 + 1;
		month = Months[days % 20];
	}

	void output() {
		cout << day << " " << month << " " << year << endl;
	}
};
int main()
{
	int n;
	cin >> n;
	cout << n << endl;
	for (int i = 0; i < n; i++) {
	Haab h;
	h.input();
	int day=h.output();
	Tzolkin z(day);
	z.output();
	}
}

Surprisingly input 10. The time will automatically ignore the rest.
So
the day into an int can save a lot of code


Published an original article · won praise 0 · Views 14

Guess you like

Origin blog.csdn.net/weixin_45549192/article/details/104295588