#include<stdio.h>
main()
{int y,m,d,leap,days;
printf("输入日期:年.月.日):");
scanf("%d.%d.%d",&y,&m,&d);
if((y%4==0 && y%100!=0) || (y%400==0))
leap=1;
else
leap=0;
days=d;
switch(m-1)
{case 12:days+=31;
case 11:days+=30;
case 10:days+=31;
case 9:days+=30;
case 8:days+=31;
case 7:days+=31;
case 6:days+=30;
case 5:days+=31;
case 4:days+=30;
case 3:days+=31;
case 2:if(leap==1)/*闰年的情况*/
days+=29;
else
days+=28;
case 1:days+=31;
}
printf("\n%d.%d.%d是该年的第%d天\n\n",y,m,d,days);
getch();
}
来自书上,第一次帮别人作弊
,