2 u011846533 u011846533 于 2014.03.26 17:08 提问

OJ 题目1186 打印日期 一直不AC 啊!求大神们看看什么问题?????

#include
#include
int a[14][2]={{0,0},{31,31},{28,29},{31,31},{30,30},{31,31},{30,30},{31,31},{31,31},{30,30},{31,31},{30,30},{31,31},{31,31}};

int isleap(int year);
int main(void)
{
int sum,i,n,year,num;
while(scanf("%d %d",&year,&num)!=EOF)
{
sum=0;
i=1;
while(sum<num)
{
sum=sum+a[i][isleap(year)];
i++;
}
i--;
n=num-(sum-a[i][isleap(year)]);
printf("%04d-%02d-%02d\n",year,i,n);

}
return 0;
}

int isleap(int year)
{
if(year%4==0 && year%100==0 || year%400==0)
{
return 1;
}
else
{
return 0;
}
}

Csdn user default icon
上传中...
上传图片
插入图片