北大ACM题1008玛雅日历那道我的代码哪里错了,求大牛之争呀 10

#include<iostream>#include<string>usingnamespacestd;staticstringhaabMonth[]={"pop","n... #include<iostream>
#include<string>
using namespace std;
static string haabMonth[]={"pop","no","zip","zotz","tzec","xul","yoxkin","mol","chen","yax","zac","ceh","mac","kankin","muan","pax","koyab","cumhu","uayet"};
static string tzolkinMonth[]={"imix","ik","akbal","kan","chicchan","cimi","manik","lamat","muluk","ok","chuen","eb","ben","ix","mem","cib","caban","eznab","canac","ahau"};
int haab_to_days(int iDay,string sMonth,int iYear){
int iMonth=1,iDays;
for(;iMonth<=19;iMonth++){
if(haabMonth[iMonth-1]==sMonth)
break;
}
iDays=(iMonth-1)*20+iDay+1+iYear*365;
return iDays;
}
int* days_to_tzolkin(int days){
int itYear=days/260;
int iDays=days%260;
int data[3];
data[0]=iDays%13;
if(data[0]==0)
data[0]==13;
data[1]=iDays%20;
if(data[1]==0)
data[1]==20;
data[2]=itYear;
return data;
}
int main()
{
int num=0;
cin>>num;
int *days=new int[num];
int iDay,iYear;
string sMonth;
for(int i=0;i<num;i++){
cin>>iDay;
getchar();
cin>>sMonth>>iYear;
days[i]=haab_to_days(iDay,sMonth,iYear);
}
if(num!=0)
cout<<endl<<num<<endl;
for(int i=0;i<num;i++){
int *p=days_to_tzolkin(days[i]);
cout<<p[0]<<" "<<tzolkinMonth[p[1]-1]<<" "<<p[2]<<endl;
}
system("pause");
return 0;
}
展开
 我来答
仁慈又漂亮丶抹香鲸5
2012-08-30
知道答主
回答量:51
采纳率:0%
帮助的人:23.8万
展开全部
#include<iostream>
#include<string>
using namespace std;
static string haabMonth[]={"pop","no","zip","zotz","tzec","xul","yoxkin","mol","chen","yax","zac","ceh","mac","kankin","muan","pax","koyab","cumhu","uayet"};
static string tzolkinMonth[]={"imix","ik","akbal","kan","chicchan","cimi","manik","lamat","muluk","ok","chuen","eb","ben","ix","mem","cib","caban","eznab","canac","ahau"};
int haab_to_days(int iDay,string sMonth,int iYear){
int iMonth=1,iDays;
for(;iMonth<=19;iMonth++){
if(haabMonth[iMonth-1]==sMonth)
break;
}
iDays=(iMonth-1)*20+iDay+1+iYear*365;
return iDays;
}
int* days_to_tzolkin(int days){
int itYear=days/260;
int iDays=days%260;
int data[3];
data[0]=iDays%13;
if(data[0]==0)
data[0]=13;
data[1]=iDays%20;
if(data[1]==0)
data[1]=20;
data[2]=itYear;
return data;
}
int main()
{
int num=0;
cin>>num;
int *days=new int[num];
int iDay,iYear;
string sMonth;
for(int i=0;i<num;i++){
cin>>iDay;
getchar();
cin>>sMonth>>iYear;
days[i]=haab_to_days(iDay,sMonth,iYear);
}
if(num!=0)
cout<<endl<<num<<endl;
for(i=0;i<num;i++){
int *p=days_to_tzolkin(days[i]);
cout<<p[0]<<" "<<tzolkinMonth[p[1]-1]<<" "<<p[2]<<endl;
}
system("pause");
return 0;
}
素心微凉冰河季
2014-07-28
知道答主
回答量:5
采纳率:0%
帮助的人:6160
展开全部
#include <stdio.h>
#include <string.h>
char hm[19][7]={"pop","no","zip","zotz","tzec","xul","yoxkin","mol","chen","yax",
"zac","ceh","mac","kankin","muan","pax","koyab","cumhu","uayet"};
char tm[20][9]={"imix","ik","akbal","kan","chicchan","cimi","manik","lamat","muluk","ok",
"chuen","eb","ben","ix","mem","cib","caban","eznab","canac","ahau"};
int main()
{
int i,m,n,day,year;
char month[9];
scanf("%d",&n);
printf("%d",n);
printf("\n");

while (n--)
{
scanf("%d. ",&day);
scanf("%s %d",month,&year);
for(i=0; i<19; i++)
if(strcmp(hm[i],month)==0)
{
m=365*year+20*i+day;
break;
}
if(m%260==0)
{
printf("%d %s %d\n", m%13+1,tm[m%20],m/260);
}
if(m%260!=0)
{
printf("%d %s %d\n",m%13+1,tm[m%20],m/260);
}
}
return 0;
}
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式