Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- bool LeapYearCheck(unsigned years)
- {
- if (((years % 4 == 0) && (years % 100 != 0)) || (years % 400 == 0))
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- int main()
- {
- long long int sec;
- long long int minutes = 0;
- long long int hours = 0;
- long long int days = 1;
- long int months = 1;
- long int years = 1970;
- cin >> sec;
- while (sec > 60)
- {
- sec -= 60;
- minutes++;
- }
- while (minutes > 60)
- {
- minutes -= 60;
- hours++;
- }
- while (hours > 24)
- {
- hours -= 24;
- days++;
- }
- while (days >= 31)
- {
- if (LeapYearCheck(years) == true)
- {
- if (31 < days && days <= 60)
- {
- days -= 31;
- months = 2;
- }
- else if (60 < days && days <= 91)
- {
- days -= 60;
- months = 3;
- }
- else if (91 < days && days <= 121)
- {
- days -= 91;
- months = 4;
- }
- else if (121 < days && days <= 152)
- {
- days -= 121;
- months = 5;
- }
- else if (152 < days && days < 182)
- {
- days -= 152;
- months = 6;
- }
- else if (182 < days && days <= 213)
- {
- days -= 182;
- months = 7;
- }
- else if (213 < days && days <= 244)
- {
- days -= 213;
- months = 8;
- }
- else if (244 < days && days <= 274)
- {
- days -= 244;
- months = 9;
- }
- else if (274 < days && days <= 305)
- {
- days -= 274;
- months = 10;
- }
- else if (305 < days && days <= 335)
- {
- days -= 305;
- months = 11;
- }
- else if (335 < days && days <= 366)
- {
- days -= 335;
- months = 12;
- }
- else if (days > 366)
- {
- days -= 365;
- years++;
- }
- }
- else if (LeapYearCheck(years) == false)
- {
- if (31 < days && days <= 59)
- {
- days -= 31;
- months = 2;
- }
- else if (59 < days && days <= 90)
- {
- days -= 59;
- months = 3;
- }
- else if (90 < days && days <= 120)
- {
- days -= 90;
- months = 4;
- }
- else if (120 < days && days <= 151)
- {
- days -= 120;
- months = 5;
- }
- else if (151 < days && days <= 181)
- {
- days -= 151;
- months = 6;
- }
- else if (181 < days && days <= 212)
- {
- days -= 181;
- months = 7;
- }
- else if (212 < days && days <= 243)
- {
- days -= 212;
- months = 8;
- }
- else if (243 < days && days <= 273)
- {
- days -= 243;
- months = 9;
- }
- else if (273 < days && days <= 304)
- {
- days -= 273;
- months = 10;
- }
- else if (304 < days && days <= 334)
- {
- days -= 304;
- months = 11;
- }
- else if (334 < days && days <= 365)
- {
- days -= 334;
- months = 12;
- }
- else if (days > 365)
- {
- days -= 364;
- years++;
- }
- }
- }
- cout << days << "." << months << "." << years << " " << hours << ":" << minutes << ":" << sec << " ";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement