POJ玛雅历

关键就是从0开始和从1开始的区别。

#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<algorithm>
using namespace std;

map<string,int> MH={
	{"pop",0}, {"no",1},{"zip",2},{"zotz",3} , {"tzec",4}, {"xul",5},
	{"yoxkin",6} ,{"mol",7} , {"chen",8},{"yax",9} ,{"zac",10} ,{"ceh",11} , 
	{"mac",12},{"kankin",13} ,{"muan",14} ,{"pax",15} ,{"koyab",16} ,{"cumhu",17},
	{"uayet",18} 
};

string MT[20]={"imix","ik", "akbal","kan" ,"chicchan" ,"cimi" , 
"manik", "lamat", "muluk", "ok","chuen" ,"eb" ,"ben" ,"ix" ,"mem" ,"cib" ,"caban" , "eznab","canac" ,"ahau" };

int main() {
	int n;
	scanf("%d",&n);
	getchar();
	printf("%d\n",n);
	
	while(n--){
		int d,m,y,days=0;;
		string M;
		char t[100],tt[10];
		gets(t);
		sscanf(t,"%d. %s %d",&d,tt,&y);
		M=tt;
		days=d+MH[M]*20+y*365+1;//days表示世界开始后的第几天 
		printf("%d %s %d\n",(days-1)%13+1,MT[(days-1)%20].c_str(),(days-1)/260); 
	}
	return 0; 
}





发布了38 篇原创文章 · 获赞 0 · 访问量 402
展开阅读全文

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 数字20 设计师: CSDN官方博客

分享到微信朋友圈

×

扫一扫,手机浏览