#include <iostream>
#include <string>
#include <cmath>
using namespace std;
int main()
{
int test;
cin >> test;
while(test--){
string str1,str2;
cin >> str1 >> str2;
int year1=0,year2=0,mon1=0,mon2=0,day1=0,day2=0;
for(int i=0; i < 4; i++){
year1=year1*10+str1[i]-'0';
year2=year2*10+str2[i]-'0';
}
for(int i=5; i < 7; i++){
mon1=mon1*10+str1[i]-'0';
mon2=mon2*10+str2[i]-'0';
}
for(int i=8; i < 10; i++){
day1=day1*10+str1[i]-'0';
day2=day2*10+str2[i]-'0';
}
//cout << year1 << " " << year2 << " " << mon1 << " " << mon2 << " " << day1 << " " << day2 << endl;
long long d1=0,d2=0;
for(int i=1; i < year1; i++){
if((i%4==0&&i%100!=0)||i%400==0) d1+=366;
else d1+=365;
}
for(int i=1; i < mon1; i++){
if(i==1||i==3||i==5||i==7||i==8||i==10||i==12) d1+=31;
else if(i==4||i==6||i==9||i==11) d1+=30;
else if(i==2){
if((year1%4==0&&year1%100!=0)||year1%400==0) d1+=29;
else d1+=28;
}
}
d1+=day1;
for(int i=1; i < year2; i++){
if((i%4==0&&i%100!=0)||i%400==0) d2+=366;
else d2+=365;
}
for(int i=1; i < mon2; i++){
if(i==1||i==3||i==5||i==7||i==8||i==10||i==12) d2+=31;
else if(i==4||i==6||i==9||i==11) d2+=30;
else if(i==2){
if((year2%4==0&&year2%100!=0)||year2%400==0) d2+=29;
else d2+=28;
}
}
d2+=day2;
//cout << d1 << " " << d2 << endl;
long long cha=d1-d2;
if(cha > 0) cout << cha << endl;
else cout << (-1)*cha << endl;
}
}
Sicily 1814日期计算问题
最新推荐文章于 2017-02-20 19:57:30 发布