poj的1008题老是显示runtime error ,求教呀,解决了加分,虽然分不多
#include<stdio.h>#include<string.h>typedefstructyears{intday;charmonth[10];intyear;}Y...
#include<stdio.h>
#include<string.h>
typedef struct years
{
int day;
char month[10];
int year;
}YEAR;
int main()
{
int day_input,number_count,index1,index2,year_input,days;
char months[156];
char holly[20][10]={"imix","ik","akbal","kan","chicchan","cimi","manik","lamat","muluk",
"ok","chuen","eb","ben","ix","mem","cib","canban","eanab","canac","ahau"};
char haab[19][10]={"pop","no","zip","zotz","tzec","xul","yoxkin","mol",
"chen","yax","zac","ceh","mac","kankin","muan","pax","koyab","cumhu","uayet" };
YEAR calendar1[10];
scanf("%d",&number_count);
for (index1=0;index1<number_count;index1++)
{
scanf("%d.%s%d",&day_input,months,&year_input);
for (index2=0;index2<19;index2++)
{
if (strcmp(months,haab[index2]))
{
continue;
}
else
{
break;
}
}
days=day_input+20*index2+365*year_input;
calendar1[index1].day=days%13+1;
calendar1[index1].year=days/260;
strcpy(calendar1[index1].month,holly[days%20]);
}
printf("%d\n",number_count);
for (index1=0;index1<number_count;index1++)
{
printf("%d %s %d\n", calendar1[index1].day,calendar1[index1].month,calendar1[index1].year);
}
return 0;
} 展开
#include<string.h>
typedef struct years
{
int day;
char month[10];
int year;
}YEAR;
int main()
{
int day_input,number_count,index1,index2,year_input,days;
char months[156];
char holly[20][10]={"imix","ik","akbal","kan","chicchan","cimi","manik","lamat","muluk",
"ok","chuen","eb","ben","ix","mem","cib","canban","eanab","canac","ahau"};
char haab[19][10]={"pop","no","zip","zotz","tzec","xul","yoxkin","mol",
"chen","yax","zac","ceh","mac","kankin","muan","pax","koyab","cumhu","uayet" };
YEAR calendar1[10];
scanf("%d",&number_count);
for (index1=0;index1<number_count;index1++)
{
scanf("%d.%s%d",&day_input,months,&year_input);
for (index2=0;index2<19;index2++)
{
if (strcmp(months,haab[index2]))
{
continue;
}
else
{
break;
}
}
days=day_input+20*index2+365*year_input;
calendar1[index1].day=days%13+1;
calendar1[index1].year=days/260;
strcpy(calendar1[index1].month,holly[days%20]);
}
printf("%d\n",number_count);
for (index1=0;index1<number_count;index1++)
{
printf("%d %s %d\n", calendar1[index1].day,calendar1[index1].month,calendar1[index1].year);
}
return 0;
} 展开
若以下回答无法解决问题,邀请你更新回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询