自己写的,运行无措,参考下吧~
#include
main()
{
int y,m,d,n=0,i=0;
int m1[]={31,28,31,30,31,30,31,31,30,31,30,31};
int m2[]={31,29,31,30,31,30,31,31,30,31,30,31};
printf("please input the date(YYYY-MM-DD):\n");
scanf("%d-%d-%d",&y,&m,&d);
if(y%4!=0&&y%400!=0) //平年判断
{ if(d>m1[m-1])
{printf("ERROR! No %dth in %d,%d.\n",d,m,y);
}
else{
while(i
i++;}
n=n+d;
printf("%d-%d-%d is the %dth day of the year %d\n",y,m,d,n,y);
}
}
else{
if(d>m2[m-1])
{printf("ERROR! No %dth in %d,%d.\n",d,m,y);
}
else{
while(i
i++;
}
n=n+d;
printf("%d-%d-%d is the %dth day of the year %d\n",y,m,d,n,y);
}
}
}