/* 判断某一日期是当年的第几天*/ |
#include"stdio.h" |
void main() |
{ |
int n,year,month,day,month_day_sum=0,sum, |
month_day[13]={0,31,28,31,30,31,30,31,31,30,31,30,31}; |
printf ( "请输入\"年月日\"\n" ); |
scanf ( "%d%d%d" ,&year,&month,&day ); |
if ( year%100!=0&&year%4==0||year%400==0 ) month_day[2]=29; |
if ( day>31||day<1||month>12||month<1 ) printf ( "错误" ); |
else |
{ |
for ( n=1; n<month; n++ ) month_day_sum+=month_day[n]; |
sum=month_day_sum+day; |
printf ( "是%d年的第%d天\n" ,year,sum ); |
} |
} |