#include<iostream>
#include "string"
using namespace std;
struct Haab
{
int day;
int month;
int year;
};
string haabname[19]={"pop","no","zip","zotz","tzec","xul","yoxkin","mol","chen",
"yax","zac","ceh","mac","kankin","muan","pax","koyab","cumhu","uayet"};
string tzolkinname[20]={"imix","ik","akbal","kan","chicchan",
"cimi","manik","lamat","muluk","ok",
"chuen","eb","ben","ix","mem",
"cib","caban","eznab","canac","ahau"};
int Dealday(char tempday[],int t)
{
int result=0;
char c;
for (int i=0;i<t;i++)
{
c=tempday[i];
if((c!='.')&&(c!='\0'))
{
result=result*10+int(c-'0');
}
else
{
break;
}
}
return result;
}
int Dealmonth(string tempmonth)
{
for (int i=0;i<19;i++)
{
if (tempmonth==haabname[i])
{
return i;
}
}
return -1;
}
int Dealyear(string tempyear)
{
int result=0;
result=atoi(tempyear.c_str());
return result;
}
void TurnHaabtoTzolkin(int num)
{
int year,month,day;
year=num/260;
month=(num%260)%20;
day=(num%260)%13+1;
cout<<day<<" ";
cout<<tzolkinname[month]<<" ";
cout<<year<<endl;
}
void Deal()
{
int alldays[1000];
int n,i;
cin>>n;
//haab h[];
Haab h[1000];
for (i=0;i<n;i++)
{
string tempmonth,tempyear;
char tempday[5];
cin>>tempday;
cin>>tempmonth;
cin>>tempyear;
tempday[sizeof(tempday)]='\0';
h[i].day=Dealday(tempday,5);
h[i].month=Dealmonth(tempmonth);
h[i].year=Dealyear(tempyear);
}
for (i=0;i<n;i++)
{
//cout<<h[i].day<<" "<<h[i].month<<" "<<h[i].year<<endl;
alldays[i]=h[i].year*365+h[i].month*20+h[i].day;//存储总天数
}
// cout<<"测试输出"<<endl;
cout<<n<<endl;
for (i=0;i<n;i++)
{
TurnHaabtoTzolkin(alldays[i]);
}
}
int main()
{
Deal();
return 0;
}
#include "string"
using namespace std;
struct Haab
{
int day;
int month;
int year;
};
string haabname[19]={"pop","no","zip","zotz","tzec","xul","yoxkin","mol","chen",
"yax","zac","ceh","mac","kankin","muan","pax","koyab","cumhu","uayet"};
string tzolkinname[20]={"imix","ik","akbal","kan","chicchan",
"cimi","manik","lamat","muluk","ok",
"chuen","eb","ben","ix","mem",
"cib","caban","eznab","canac","ahau"};
int Dealday(char tempday[],int t)
{
int result=0;
char c;
for (int i=0;i<t;i++)
{
c=tempday[i];
if((c!='.')&&(c!='\0'))
{
result=result*10+int(c-'0');
}
else
{
break;
}
}
return result;
}
int Dealmonth(string tempmonth)
{
for (int i=0;i<19;i++)
{
if (tempmonth==haabname[i])
{
return i;
}
}
return -1;
}
int Dealyear(string tempyear)
{
int result=0;
result=atoi(tempyear.c_str());
return result;
}
void TurnHaabtoTzolkin(int num)
{
int year,month,day;
year=num/260;
month=(num%260)%20;
day=(num%260)%13+1;
cout<<day<<" ";
cout<<tzolkinname[month]<<" ";
cout<<year<<endl;
}
void Deal()
{
int alldays[1000];
int n,i;
cin>>n;
//haab h[];
Haab h[1000];
for (i=0;i<n;i++)
{
string tempmonth,tempyear;
char tempday[5];
cin>>tempday;
cin>>tempmonth;
cin>>tempyear;
tempday[sizeof(tempday)]='\0';
h[i].day=Dealday(tempday,5);
h[i].month=Dealmonth(tempmonth);
h[i].year=Dealyear(tempyear);
}
for (i=0;i<n;i++)
{
//cout<<h[i].day<<" "<<h[i].month<<" "<<h[i].year<<endl;
alldays[i]=h[i].year*365+h[i].month*20+h[i].day;//存储总天数
}
// cout<<"测试输出"<<endl;
cout<<n<<endl;
for (i=0;i<n;i++)
{
TurnHaabtoTzolkin(alldays[i]);
}
}
int main()
{
Deal();
return 0;
}
作者:s1102379635 发表于2013-3-31 14:25:08 原文链接
阅读:39 评论:0 查看评论