代码如下,如有帮助,请采纳一下,谢谢。
#include <stdio.h>
int main()
{
int year,mon,day;
int i;
int nmb = 0;
scanf("%d %d %d",&year,&mon,&day);
for (i = 1; i < mon;i++)
{
switch(i)
{
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
nmb += 31;
break;
case 4:
case 6:
case 9:
case 11:
nmb += 30;
break;
case 2:
if (year % 4 == 0 && year %100 != 0 ||year % 400 == 0)
nmb += 29;
else
nmb += 28;
break;
}
}
nmb += day;
printf("%d年%d月%d日是该年的第%d天\n",year,mon,day,nmb);
return 0;
}