当前位置: 首页 > 工具软件 > ZK Calendar > 使用案例 >

1008 Maya Calendar 解体思路

袁枫涟
2023-12-01

该题比较简单,废话不多说,上程序。

#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <utility>


using namespace std;



struct data11
{
	int first;
	string second;
	int third;
};


//1008 Maya Calendar
int main()
{
	int len;
	cin >> len;
	int i=0;

	string str1 ,str2;
	int year_Haab,day_Haab,mouth_Haab;
	int year_Tzk,day20_Tzk,day13_Tzk;
	
	int day;
	//pair<int,int> a;
	vector< struct data11 > vec;
	
	while(i<len)
	{
		i++;

		cin>>str1>>str2>>year_Haab;
		
		day_Haab = atoi(str1.c_str());
//pop, no, zip, zotz, tzec, xul, yoxkin, mol, chen, yax, zac, ceh, mac, kankin, muan, pax, koyab, cumhu.
		if(str2 == "pop")		mouth_Haab=1;
		else if(str2 == "no")	mouth_Haab=2;
		else if(str2 == "zip")	mouth_Haab=3;
		else if(str2 == "zotz")	mouth_Haab=4;
		else if(str2 == "tzec")	mouth_Haab=5;
		else if(str2 == "xul")	mouth_Haab=6;
		else if(str2 == "yoxkin")	mouth_Haab=7;
		else if(str2 == "mol")	mouth_Haab=8;
		else if(str2 == "chen")	mouth_Haab=9;
		else if(str2 == "yax")	mouth_Haab=10;
		else if(str2 == "zac")	mouth_Haab=11;
		else if(str2 == "ceh")	mouth_Haab=12;
		else if(str2 == "mac")	mouth_Haab=13;
		else if(str2 == "kankin")	mouth_Haab=14;
		else if(str2 == "muan")	mouth_Haab=15;
		else if(str2 == "pax")	mouth_Haab=16;
		else if(str2 == "koyab")	mouth_Haab=17;
		else if(str2 == "cumhu")	mouth_Haab=18;
		else if(str2 == "uayet")	mouth_Haab=19;

		day = year_Haab*365 + (mouth_Haab-1)*20 + day_Haab;

		year_Tzk = day/(20*13);
		day20_Tzk = day%(20*13)%20+1;
		day13_Tzk = day%(20*13)%13+1;
//imix, ik, akbal, kan, chicchan, cimi, manik, lamat, muluk, ok, chuen, eb, ben, ix, mem, cib, caban, eznab, canac, ahau
		string s;
		switch(day20_Tzk)
		{
		case 1: s = "imix"; break;
		case 2: s = "ik" ;break;
		case 3: s = "akbal" ;break;
		case 4: s = "kan" ;break;
		case 5: s = "chicchan" ;break;

		case 6: s = "cimi" ;break;
		case 7: s = "manik" ;break;
		case 8: s = "lamat" ;break;
		case 9: s = "muluk" ;break;
		case 10: s = "ok" ;break;

		case 11: s = "chuen" ;break;
		case 12: s = "eb" ;break;
		case 13: s = "ben" ;break;
		case 14: s = "ix" ;break;
		case 15: s = "mem" ;break;

		case 16: s = "cib" ;break;
		case 17: s = "caban" ;break;
		case 18: s = "eznab" ;break;
		case 19: s = "canac" ;break;
		case 20: s = "ahau" ;break;
			
		}
		
		struct data11 d;
		d.first = day13_Tzk ;
		d.second = s;
		d.third = year_Tzk ;
		vec.push_back(d);
		
		
	}

	cout << len << endl;
	for(i=0;i<vec.size();i++)
	{
		cout << vec[i].first << " " << vec[i].second << " " << vec[i].third << endl;		
	}
	
	return 0;
}


 类似资料: