#include <stdio.h>
int main()
{
/* 定义需要计算的日期 */
int year = 2008;
int month = 8;
int day = 8;
switch(month)
{
case 1:day;break;
case 2:day+=31;break;
case 3:day+=60;break;
case 4:day+=91;break;
case 5:day+=121;break;
case 6:day+=152;break;
case 7:day+=182;break;
case 8:day+=213;break;
case 9:day+=244;break;
case 10:day+=274;break;
case 11:day+=305;break;
case 12:day+=335;break;
}
if(month>=2)//判断是不是大于或者等于二月否则直接printf
{
if((year%4==0&&year%100!=0)||(year%400==0))
printf("%d年%d月8日是该年的第%d天\n",year,month,day);
else printf("是%d年%d月8日是该年的第%d天\n",year,month,--day);
}
else printf("%d年%d月8日是该年的第%d天\n",year,month,day);
return 0;
}
仅供参考