#include <stdio.h>
#include<math.h>
main()
{
int num,leap,n,m,sum1=0,sum2=0,i,year,month,day;
int a[2][12]={{31,29,31,30,31,30,31,31,30,31,31,30},{31,28,31,30,31,30,31,31,30,31,31,30}};
printf("请输入年月日:");
scanf("%5d%3d%3d",&year,&month,&day);
leap=year%4==0&&year%100!=0||year%400==0;
for(i=1;i<month;i++)
day=day+a[leap][i];
m=year-2000;
n=m/4;
for(i=0;i<12;i++)
{
sum1=sum1+a[0][i];
sum2=sum2+a[1][i];
}
num=n*sum2+(m-n)*sum1+day-1;
printf("距2000年1月1日的天数为:");
printf("%5d\n",num);
}
你再看看这个程序吧,还算简略!
[
本帖最后由 龙航四海 于 2012-10-30 22:14 编辑 ]