计算日期之间的天数
#include<iostream>
#include<cstdio>
#include <stdlib.h>
#include <stack>
#include <string>
#include<queue>
#include<math.h>
//#include<vector>
using namespace std;
bool is_leep(int year)
{
return ((year%4==0 && year%100==0)||(year%400==0))? 1:0;
}
int main()
{
/*
int a;
int b;
cin>>a;
cin>>b;
*/
int mounth[12][2]={
{31,31},{28,29},{31,31},{30,30},{31,31},{30,30},{31,31},{31,31},{30,30},{31,31},{30,30},{31,31}
};
int y1,m1,d1,time1;
int y2,m2,d2,time2;
int exc=0;
cin>>time1;
cin>>time2;
if(time1>time2)//---确定t2大于t1
{
exc=time1;
time1=time2;
time2=exc;
}
y1=time1/10000;
m1=(time1-(y1*10000))/100;
d1=time1-(y1*10000)-(m1*100);
y2=time2/10000;
m2=(time2-(y2*10000))/100;
d2=time2-(y2*10000)-(m2*100);
cout<<y1<<","<<m1<<","<<d1<<endl;
cout<<y2<<","<<m2<<","<<d2<<endl;
//===========第一个日期没有达到第二个就继续循环
int count1=0;
do{
d1++;
if(d1==mounth[m1-1][is_leep(y1)]+1){
m1++;
d1=1;
}
if(m1==13)
{
y1++;
m1=1;
}
count1++;
}while(y1<y2||m1<m2||d1<d2);
/*
while(y1<y2||m1<m2||d1<d2)
{
d1++;
if(d1==mounth[m1][is_leep(y1)]+1){
m1++;
d1=1;
}
if(m1==13)
{
y1++;
m1=1;
}
count1++;
}
*/
cout<<count1+1<<endl;
//cout<<is_leep(2019)<<endl;
return 0;
}
/*
20141015
20141011
*/