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.

37 lines
954 B

#include <iostream>
using namespace std;
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() {
int days = 0;
//2019,2020
if (LeapYear(2019))days += 366; else days += 365;
if (LeapYear(2020))days += 366; else days += 365;
//2021
if (LeapYear(2021))
for (int i = 1; i <= 3; ++i) days += months_2[i];
else
for (int i = 1; i <= 3; ++i) days += months_1[i];
days+=9;
//2018
int d2 = 0;
if (LeapYear(2018))
for (int i = 1; i <= 3; ++i)d2 += months_2[i];
else
for (int i = 1; i <= 3; ++i) d2 += months_1[i];
d2 += 17;
if (LeapYear(2018)) days += 366 - d2;
else days += 365 - d2;
cout << days;
return 0;
}