编程计算两个日期之间的天数

2025-04-28 19:52:53
推荐回答(2个)
回答1:

主函数的功能是输入2个日期,然后求2个日期之间的总天数。
totoaldays的函数就是求从公元0年开始到输入日期之间的总天数。
long totaldays(int year,int month,int day)/*公元纪年的总天数*/
{ int days[]={0,31,28,31,30,31,30,31,31,30,31,30,31};
int c=day,m,y=year-1;
days[2]=28+LEAP(year); //确定今年2月的天数
for(m=1;m return c+y/4-y/100+y/400+y*365L; //计算方法是先计算假如全部年份都是平年的天数即y*365L,然后加c,c是year那一年的天数,再加上闰年出现的次数。
}

回答2:

this time i was quiet sure the beauty i was enjoy i was far beyond their perception of the saving time