//繁琐但直接的思路
#include<iostream>
using namespace std;
int yy[2][12]={ //每月天数
{31,28,31,30,31,30,31,31,30,31,30,31},
{31,29,31,30,31,30,31,31,30,31,30,31}
};
bool isrun(int year){ //判断闰年
return ((year%4==0&&year%100!=0)||year%400==0);
}
int rundays(int year){ //对应天数
if(isrun(year))return 366;
else return 365;
}
bool compare(int year1,int month1,int day1,int year2,int month2,int day2){ //比较日期前后
if(year1>year2||(year1==year2&&month1>month2)||(year1==year2&&month1==month2&&day1>day2))
return false;
else return true;
}
int main(){
char s1[9],s2[9];
int year1,month1,day1,year2,month2,day2;
while(cin>>s1>>s2){
int number=1; //数据处理(直接用int做除法应该更简单)
year1=(s1[0]-'0')*1000+(s1[1]-'0')*100+(s1[2]-'0')*10+(s1[3]-'0');
month1=(s1[4]-'0')*10+(s1[5]-'0');
day1=(s1[6]-'0')*10+(s1[7]-'0');
year2=(s2[0]-'0')*1000+(s2[1]-'0')*100+(s2[2]-'0')*10+(s2[3]-'0');
month2=(s2[4]-'0')*10+(s2[5]-'0');
day2=(s2[6]-'0')*10+(s2[7]-'0');
if(!compare(year1,month1,day1,year2,month2,day2)) { //较小日期放到前面
int t;
t=year1;
year1=year2;
year2=t;
t=month1;
month1=month2;
month2=t;
t=day1;
day1=day2;
day2=t;
}
//分情况从第一个日期开始累计
if(year1!=year2){ //不同年
int run=isrun(year1);
number+=yy[run][month1-1]-day1;
while(month1<12)number+=yy[run][month1++];
year1++;
while(year1<year2){
number+=rundays(year1++);
}
run=isrun(year2);
while(month2>1)number+=yy[run][(month2--)-2];
number+=day2;
}
else if(month1!=month2){ //同年不同月
int run=isrun(year1);
number+=yy[run][month1-1]-day1;
while(month1+1<month2)number+=yy[run][month1++];
number+=day2;
}
else number+=(day2-day1); //同年同月不同日
cout<<number<<endl;
}
return 0;
}
#include<iostream>
using namespace std;
int yy[2][12]={ //每月天数
{31,28,31,30,31,30,31,31,30,31,30,31},
{31,29,31,30,31,30,31,31,30,31,30,31}
};
bool isrun(int year){ //判断闰年
return ((year%4==0&&year%100!=0)||year%400==0);
}
int rundays(int year){ //对应天数
if(isrun(year))return 366;
else return 365;
}
bool compare(int year1,int month1,int day1,int year2,int month2,int day2){ //比较日期前后
if(year1>year2||(year1==year2&&month1>month2)||(year1==year2&&month1==month2&&day1>day2))
return false;
else return true;
}
int main(){
char s1[9],s2[9];
int year1,month1,day1,year2,month2,day2;
while(cin>>s1>>s2){
int number=1; //数据处理(直接用int做除法应该更简单)
year1=(s1[0]-'0')*1000+(s1[1]-'0')*100+(s1[2]-'0')*10+(s1[3]-'0');
month1=(s1[4]-'0')*10+(s1[5]-'0');
day1=(s1[6]-'0')*10+(s1[7]-'0');
year2=(s2[0]-'0')*1000+(s2[1]-'0')*100+(s2[2]-'0')*10+(s2[3]-'0');
month2=(s2[4]-'0')*10+(s2[5]-'0');
day2=(s2[6]-'0')*10+(s2[7]-'0');
if(!compare(year1,month1,day1,year2,month2,day2)) { //较小日期放到前面
int t;
t=year1;
year1=year2;
year2=t;
t=month1;
month1=month2;
month2=t;
t=day1;
day1=day2;
day2=t;
}
//分情况从第一个日期开始累计
if(year1!=year2){ //不同年
int run=isrun(year1);
number+=yy[run][month1-1]-day1;
while(month1<12)number+=yy[run][month1++];
year1++;
while(year1<year2){
number+=rundays(year1++);
}
run=isrun(year2);
while(month2>1)number+=yy[run][(month2--)-2];
number+=day2;
}
else if(month1!=month2){ //同年不同月
int run=isrun(year1);
number+=yy[run][month1-1]-day1;
while(month1+1<month2)number+=yy[run][month1++];
number+=day2;
}
else number+=(day2-day1); //同年同月不同日
cout<<number<<endl;
}
return 0;
}