You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
1.0 KiB
39 lines
1.0 KiB
#include <iostream>
|
|
|
|
using namespace std;
|
|
int days, y1, y2, m1, m2, d1, d2;
|
|
const int N = 13;
|
|
int months_1[N] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
|
|
int months_2[N] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
|
|
|
|
bool LeapYear(int year) {
|
|
return ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0);
|
|
}
|
|
|
|
int main() {
|
|
cin >> y1 >> m1 >> d1 >> y2 >> m2 >> d2;
|
|
//2000.2.3--- 2009.8.9
|
|
// [2001,2002,2003,2004,2005,2006,2007,2008]
|
|
//y1+1--->y2-1
|
|
for (int i = y1 + 1; i <= y2 - 1; i++) {
|
|
if (LeapYear(i))days += 366;
|
|
else days += 365;
|
|
}
|
|
//y2
|
|
for (int i = 1; i <= m2 - 1; i++)
|
|
if (LeapYear(y2)) days += months_2[i];
|
|
else days += months_1[i];
|
|
days += d2;
|
|
|
|
//y1
|
|
int d0 = 0;
|
|
for (int i = 1; i <= m1 - 1; i++)
|
|
if (LeapYear(y1)) d0 += months_2[i];
|
|
else d0 += months_1[i];
|
|
d0 += d1 - 1;
|
|
if (LeapYear(y1))days += 366 - d0;
|
|
else days += 365 - d0;
|
|
//输出
|
|
cout << days - 1 << endl;
|
|
return 0;
|
|
} |