问题描述
- 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-%02dn",year,i,n);}
return 0;
}int isleap(int year)
{
if(year%4==0 && year%100==0 || year%400==0)
{
return 1;
}
else
{
return 0;
}
}
时间: 2024-11-05 06:10:28