北大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;
} 展开
#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;
} 展开
2个回答
展开全部
#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;
}
#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;
}
展开全部
#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;
}
#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;
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询