POJ 1008 Maya Calendar

Title description

Insert picture description here
The difficulty of this question is not great, it is just a date conversion. I have done this question a long time ago.

1. First convert the entered date to the number of days from the beginning of the date: date = year 365+month 20+days

2. Find the year, month, and day of the Tzolkin calendar format according to date

     year = date/260;
     数字=date%13+1; (加1是因为数字从1开始)
     天名字下标=date%20;(20个天名字的下标从0到19,根据计算出的天名字下标就可以得到相应的天名字)
#include <iostream>
#include <string>
using namespace std;

string Month[] = {
    
     "pop", "no", "zip", "zotz", "tzec", "xul", "yoxkin", "mol", "chen", "yax", "zac", "ceh", "mac", "kankin", "muan", "pax", "koyab", "cumhu", "uayet" };
string Cycle[] = {
    
     "imix", "ik", "akbal", "kan", "chicchan", "cimi", "manik", "lamat", "muluk", "ok", "chuen", "eb", "ben", "ix", "mem", "cib", "caban", "eznab", "canac", "ahau" };

int main(){
    
    
	int n;
	cin>>n;
	float day;
	string month;
	int mm;
	int year;
	int date;
	int i;
	cout<<n<<endl;
	while(n--){
    
    
		cin>>day>>month>>year;
		for(i=0;i<19;i++){
    
    
			if(month==Month[i])
			break;
		}
		date=365*year+20*i+day;
		year=date/260;
		mm=date%13+1;
		day=date%20;
		cout<<mm<<" "<<Cycle[(int)day]<<" "<<year<<endl;
	}
}

Guess you like

Origin blog.csdn.net/qaqaqa666/article/details/112856961