#include #include class Date { public: Date(int year, int month, int day) { Year = year; Day = day; Month = month; if (IsLeap()) { days_in_month[1] = 29; } } bool IsLeap() const { if (Year % 400 == 0) { return true; } else if (Year % 100 == 0) { return false; } else if (Year % 4 == 0) { return true; } else { return false; } } std::string ToString() const { std::string ans, day_s, month_s, year_s; day_s = std::to_string(Day); if (Day < 10) { day_s = '0' + day_s; } month_s = std::to_string(Month); if (Month < 10) { month_s = '0' + month_s; } year_s = std::to_string(Year); while (year_s.size() < 4) { year_s = '0' + year_s; } ans = day_s + '.' + month_s + '.' + year_s; return ans; } Date DaysLater(int days) const { int count = 0; Date ans = Date(Year, Month, Day); while (count != days) { ans.Day++; count++; if (days_in_month[ans.Month - 1] < ans.Day) { ans.Month++; ans.Day = 1; } if (ans.Month > 12) { ans.Year++; ans.Month %= 12; } } return ans; } int DaysLeft(const Date& date) const { // 02.01.2000 11.01.2000 int count = 0; Date ans = Date(Year, Month, Day); while (date.Day != ans.Day || date.Month != ans.Month || date.Year != ans.Year) { ans.Day++; count++; if (days_in_month[ans.Month - 1] < ans.Day) { ans.Month++; ans.Day = 1; } if (ans.Month > 12) { ans.Year++; ans.Month %= 12; } } return count; } private: int Year, Month, Day; std::vector days_in_month = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; };