北大oj上的一道题,哪位高手有兴趣解答下,感激不尽 http://poj.org/problem?id=1008
2个回答
展开全部
#include <iostream>
#include <string>
using namespace std;
int main()
{
int n,i,d,y,t,num,j;
char x;
char m[10];
char a[19][8]={"pop","no","zip","zotz","tzec","xul","yoxkin","mol","chen", "yax", "zac",
"ceh","mac","kankin","muan","pax","koyab","cumhu","uayet"};
char b[20][20]={"imix", "ik","akbal", "kan","chicchan","cimi","manik","lamat","muluk",
"ok","chuen","eb","ben","ix","mem","cib","caban","eznab","canac","ahau"};
cin >> n;
cout << n << endl;
while(n--)
{
cin>>d>>x>>m>>y;
for(i=0;i<19;i++)
if(strcmp(m,a[i])==0)
{
num=y*365+i*20+d+1;
break;
}
y=num/260;
t=num%260;
if(t==0) y--;
d=t%13;
if(d==0) d = 13;
j=t%20;
if(j==0) j = 20;
strcpy(m,b[j-1]);
cout<<d<<' '<<m<<' '<<y<<endl;
}
return 0;
}
#include <string>
using namespace std;
int main()
{
int n,i,d,y,t,num,j;
char x;
char m[10];
char a[19][8]={"pop","no","zip","zotz","tzec","xul","yoxkin","mol","chen", "yax", "zac",
"ceh","mac","kankin","muan","pax","koyab","cumhu","uayet"};
char b[20][20]={"imix", "ik","akbal", "kan","chicchan","cimi","manik","lamat","muluk",
"ok","chuen","eb","ben","ix","mem","cib","caban","eznab","canac","ahau"};
cin >> n;
cout << n << endl;
while(n--)
{
cin>>d>>x>>m>>y;
for(i=0;i<19;i++)
if(strcmp(m,a[i])==0)
{
num=y*365+i*20+d+1;
break;
}
y=num/260;
t=num%260;
if(t==0) y--;
d=t%13;
if(d==0) d = 13;
j=t%20;
if(j==0) j = 20;
strcpy(m,b[j-1]);
cout<<d<<' '<<m<<' '<<y<<endl;
}
return 0;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询