个人不明白为什么提交代码后会得到runtime error的结果,求指点迷津
这是题目内容以下是本人代码
#include<stdio.h>
int main()
{
int year,month,day,k,sum,i;
int a[2][13]=
{
{0,31,28,31,30,31,30,31,31,30,31,30,31},
{0,31,29,31,30,31,30,31,31,30,31,30,31},
};
while(scanf("%d%d%d",&year,&month,&day)!=EOF)
{
if((year%4==0&&year%100!=0)||(year%400==0))
k=1;
else
k=0;
if(month>12)
printf("Illegal date\n");
else if(day>a[k][month])
printf("Illegal date\n");
else
{
sum=0;
i=1;
while(i!=month)
{
sum=sum+a[k][i];
i++;
}
sum=sum+day;
printf("%d\n",sum);
}
}
return 0;
}
[ 本帖最后由 ma815841356 于 2015-5-6 00:43 编辑 ]