poj 1008 Maya Calendar(简单模拟)

最近在做模拟题,感觉自己编码能力太差了,想通过模拟题好好提高一下编码能力!

这是一道简单的编码题,本以为可以很快就解决的,结果几乎花了我一上午的时间,失败啊~~~

最后看了discuss里给的一组测试数据才把它给过了,唉,考虑问题不全面啊!!直接打表就行了~

贴代码:

#include<stdio.h>
#include<string.h>
#include<iostream>
using namespace std;

struct node
{
int d;
char mon[10];
};
node date[260] = {{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"},{11,"kan"},{12,"chicchan"},{13,"cimi"},{1,"manik"},{2,"lamat"},
{3,"muluk"},{4,"ok"},{5,"chuen"},{6,"eb"},{7,"ben"},{8,"ix"},{9,"mem"},{10,"cib"},{11,"caban"},{12,"eznab"},{13,"canac"},{1,"ahau"},{2,"imix"},{3,"ik"},{4,"akbal"},
{5,"kan"},{6,"chicchan"},{7,"cimi"},{8,"manik"},{9,"lamat"},{10,"muluk"},{11,"ok"},{12,"chuen"},{13,"eb"},{1,"ben"},{2,"ix"},{3,"mem"},{4,"cib"},{5,"caban"},
{6,"eznab"},{7,"canac"},{8,"ahau"},{9,"imix"},{10,"ik"},{11,"akbal"},{12,"kan"},{13,"chicchan"},{1,"cimi"},{2,"manik"},{3,"lamat"},{4,"muluk"},{5,"ok"},{6,"chuen"},
{7,"eb"},{8,"ben"},{9,"ix"},{10,"mem"},{11,"cib"},{12,"caban"},{13,"eznab"},{1,"canac"},{2,"ahau"},{3,"imix"},{4,"ik"},{5,"akbal"},{6,"kan"},{7,"chicchan"},
{8,"cimi"},{9,"manik"},{10,"lamat"},{11,"muluk"},{12,"ok"},{13,"chuen"},{1,"eb"},{2,"ben"},{3,"ix"},{4,"mem"},{5,"cib"},{6,"caban"},{7,"eznab"},{8,"canac"},
{9,"ahau"},{10,"imix"},{11,"ik"},{12,"akbal"},{13,"kan"},{1,"chicchan"},{2,"cimi"},{3,"manik"},{4,"lamat"},{5,"muluk"},{6,"ok"},{7,"chuen"},{8,"eb"},{9,"ben"},
{10,"ix"},{11,"mem"},{12,"cib"},{13,"caban"},{1,"eznab"},{2,"canac"},{3,"ahau"},{4,"imix"},{5,"ik"},{6,"akbal"},{7,"kan"},{8,"chicchan"},{9,"cimi"},{10,"manik"},
{11,"lamat"},{12,"muluk"},{13,"ok"},{1,"chuen"},{2,"eb"},{3,"ben"},{4,"ix"},{5,"mem"},{6,"cib"},{7,"caban"},{8,"eznab"},{9,"canac"},{10,"ahau"},{11,"imix"},
{12,"ik"},{13,"akbal"},{1,"kan"},{2,"chicchan"},{3,"cimi"},{4,"manik"},{5,"lamat"},{6,"muluk"},{7,"ok"},{8,"chuen"},{9,"eb"},{10,"ben"},{11,"ix"},{12,"mem"},
{13,"cib"},{1,"caban"},{2,"eznab"},{3,"canac"},{4,"ahau"},{5,"imix"},{6,"ik"},{7,"akbal"},{8,"kan"},{9,"chicchan"},{10,"cimi"},{11,"manik"},{12,"lamat"},
{13,"muluk"},{1,"ok"},{2,"chuen"},{3,"eb"},{4,"ben"},{5,"ix"},{6,"mem"},{7,"cib"},
{8,"caban"},{9,"eznab"},{10,"canac"},{11,"ahau"},{12,"imix"},{13,"ik"},{1,"akbal"},{2,"kan"},{3,"chicchan"},{4,"cimi"},{5,"manik"},{6,"lamat"},{7,"muluk"},{8,"ok"},
{9,"chuen"},{10,"eb"},{11,"ben"},{12,"ix"},{13,"mem"},{1,"cib"},{2,"caban"},{3,"eznab"},{4,"canac"},{5,"ahau"},{6,"imix"},{7,"ik"},{8,"akbal"},{9,"kan"},
{10,"chicchan"},{11,"cimi"},{12,"manik"},{13,"lamat"},{1,"muluk"},{2,"ok"},{3,"chuen"},{4,"eb"},{5,"ben"},{6,"ix"},{7,"mem"},{8,"cib"},{9,"caban"},{10,"eznab"},
{11,"canac"},{12,"ahau"},{13,"imix"},{1,"ik"},{2,"akbal"},{3,"kan"},{4,"chicchan"},{5,"cimi"},{6,"manik"},{7,"lamat"},{8,"muluk"},{9,"ok"},{10,"chuen"},{11,"eb"},
{12,"ben"},{13,"ix"},{1,"mem"},{2,"cib"},{3,"caban"},{4,"eznab"},{5,"canac"},{6,"ahau"},{7,"imix"},{8,"ik"},{9,"akbal"},{10,"kan"},{11,"chicchan"},{12,"cimi"},
{13,"manik"},{1,"lamat"},{2,"muluk"},{3,"ok"},{4,"chuen"},{5,"eb"},{6,"ben"},{7,"ix"},{8,"mem"},{9,"cib"},{10,"caban"},{11,"eznab"},{12,"canac"},{13,"ahau"}};
char mon[19][10]={"pop","no","zip","zotz","tzec" ,"xul","yoxkin","mol","chen","yax","zac","ceh","mac","kankin","muan","pax","koyab","cumhu","uayet"};


int main()
{
int d,y,n,sum,i,k;
char s[10],x;

scanf("%d",&n);
printf("%d\n",n);
while(n--)
{
cin>>d>>x>>s>>y;
for(i=0;i<19;i++)
if(strcmp(s,mon[i])==0)
break;
sum=y*365+i*20+d+1;
if(sum%260)
printf("%d %s %d\n",date[sum%260-1].d,date[sum%260-1].mon,sum/260);
else
printf("%d %s %d\n",date[259].d,date[259].mon,sum/260-1);
}
return 0;
}



转载于:https://www.cnblogs.com/misty1/archive/2012/04/07/2435751.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值