功能:输入某年某月某日,判断这一天是这一年的第几天?
#include<stdio.h>
main()
{int y,m,day,d=0,f;
printf("请输入某年的某月某日:");
scanf("%d%d%d",&y,&m,&day);
if(y%4==0&&y%100!=0||y%400==0)
f=29;
else
f=28;
switch(m)
{case1:d=day;break;
case2:d=31+day;break;
case3:d=31+f+day;break;
case4:d=31+f+30+day;break;
case5:d=31*2+f+30+day;break;
case6:d=31*3+f+30+day;break;
case7:d=31*3+f+30*2+day;break;
case8:d=31*4+f+30*2+day;break;
case9:d=31*5+f+30*2+day;break;
case10:d=31*5+f+30*3+day;break;
case11:d=31*6+f+30*3+day;break;
case12:d=31*6+f+30*4+day;break;}
printf("%d年%d月%d日为一年的第%d天",y,m,day,d);}