题意:玛雅日历有两种,第一种一年365天19个月前18个月每月20天,第19月5天,第二种日历是一年260天,13个月每月20天,每月有两种计算天数的一种是英文,一种是1~13天。
题外话:现在为止我还是极少接触算法,这道题听说是简单的模拟题。虽然我的bug太多改了很久,但是我还是觉得极大增强了我的信心。
#include
#include
char Haab[25][10] = {"pop","no","zip","zotz","tzec","xul","yoxkin","mol","chen","yax","zac","ceh","mac","kankin","muan","pax","koyab","cumhu","uayet"}; //没有对第19月单独处理,是因为不影响。
char Tzo[25][10] = {"imix","ik","akbal","kan","chicchan","cimi","manik","lamat","muluk","ok","chuen","eb","ben","ix","mem","cib","caban","eznab","canac","ahau"};
int manth(char a[])
{
int i;
for(i = 0;i < 19; i++)
if(strcmp(Haab[i],a) == 0)
return i;
return -1;
}
int main()
{
int n;
scanf("%d",&n);
printf("%d\n",n);
while(n--)
{
int day1,year1;
char m[10];
scanf("%d.%s%d",&day1,m,&year1);
long allday = year1*365 + manth(m)*20 + day1;
long year2 = allday/260;
long day2 = allday%260;
printf("%ld %s %ld\n",day2%13+1,Tzo[day2%20],year2); //天数要加1,因为题中说对一天有差值1
}
return 0;
}
#include
#include
using namespace std;
string Haab[19] = {"pop","no","zip","zotz","tzec","xul","yoxkin","mol","chen","yax","zac","ceh","mac","kankin","muan","pax","koyab","cumhu","uayet"};
string Tzo[20] = {"imix","ik","akbal","kan","chicchan","cimi","manik","lamat","muluk","ok","chuen","eb","ben","ix","mem","cib","caban","eznab","canac","ahau"};
int manth(string a)
{
int i;
for(i = 0;i < 19; i++)
if(Haab[i] == a)
return i;
return -1;
}
int main()
{
int n;
cin>>n;
cout<>day1>>manth1>>manth1>>year1;
long allday = year1*365 + manth(manth1)*20 + day1;
long year2 = allday/260;
long day2 = allday%260;
cout<