5.设计一个日历程序,输入年月日,输出第多少天
#include<stdio.h>
int main()
{
printf(“please input date…\n”);
int month,year,day,j;
int sum=0;
scanf("%d %d %d",&year,&month,&day);
if(year%40||year%4000&&year%100!=0)
{
int
a[12]={31,29,31,30,31,30,31,31,30,31,30,31};
for(j=month-2;j>=0;j–)
{
sum=sum+a[j];
}
sum=sum+day;
}
else
{
int
a[12]={31,28,31,30,31,30,31,31,30,31,30,31};
for(j=month-2;j>=0;j–)
{
sum=sum+a[j];
}
sum=sum+day;
}
printf(“the day is %d days
in the year\n”,sum );
return 0;
}