Advertisement
monito2207

Untitled

Nov 21st, 2021
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.80 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. bool LeapYearCheck(unsigned years)
  5. {
  6. if (((years % 4 == 0) && (years % 100 != 0)) || (years % 400 == 0))
  7. {
  8. return true;
  9. }
  10. else
  11. {
  12. return false;
  13. }
  14. }
  15.  
  16. int main()
  17. {
  18. long long int sec;
  19. long long int minutes = 0;
  20. long long int hours = 0;
  21. long long int days = 1;
  22. long int months = 1;
  23. long int years = 1970;
  24.  
  25. cin >> sec;
  26.  
  27. while (sec > 60)
  28. {
  29. sec -= 60;
  30. minutes++;
  31. }
  32. while (minutes > 60)
  33. {
  34. minutes -= 60;
  35. hours++;
  36. }
  37. while (hours > 24)
  38. {
  39. hours -= 24;
  40. days++;
  41. }
  42. while (days >= 31)
  43. {
  44. if (LeapYearCheck(years) == true)
  45. {
  46. if (31 < days && days <= 60)
  47. {
  48. days -= 31;
  49. months = 2;
  50. }
  51. else if (60 < days && days <= 91)
  52. {
  53. days -= 60;
  54. months = 3;
  55. }
  56. else if (91 < days && days <= 121)
  57. {
  58. days -= 91;
  59. months = 4;
  60. }
  61. else if (121 < days && days <= 152)
  62. {
  63. days -= 121;
  64. months = 5;
  65. }
  66. else if (152 < days && days < 182)
  67. {
  68. days -= 152;
  69. months = 6;
  70. }
  71. else if (182 < days && days <= 213)
  72. {
  73. days -= 182;
  74. months = 7;
  75. }
  76. else if (213 < days && days <= 244)
  77. {
  78. days -= 213;
  79. months = 8;
  80. }
  81. else if (244 < days && days <= 274)
  82. {
  83. days -= 244;
  84. months = 9;
  85. }
  86. else if (274 < days && days <= 305)
  87. {
  88. days -= 274;
  89. months = 10;
  90. }
  91. else if (305 < days && days <= 335)
  92. {
  93. days -= 305;
  94. months = 11;
  95. }
  96. else if (335 < days && days <= 366)
  97. {
  98. days -= 335;
  99. months = 12;
  100. }
  101. else if (days > 366)
  102. {
  103. days -= 365;
  104. years++;
  105. }
  106.  
  107. }
  108. else if (LeapYearCheck(years) == false)
  109. {
  110. if (31 < days && days <= 59)
  111. {
  112. days -= 31;
  113. months = 2;
  114. }
  115. else if (59 < days && days <= 90)
  116. {
  117. days -= 59;
  118. months = 3;
  119. }
  120. else if (90 < days && days <= 120)
  121. {
  122. days -= 90;
  123. months = 4;
  124. }
  125. else if (120 < days && days <= 151)
  126. {
  127. days -= 120;
  128. months = 5;
  129. }
  130. else if (151 < days && days <= 181)
  131. {
  132. days -= 151;
  133. months = 6;
  134. }
  135. else if (181 < days && days <= 212)
  136. {
  137. days -= 181;
  138. months = 7;
  139. }
  140. else if (212 < days && days <= 243)
  141. {
  142. days -= 212;
  143. months = 8;
  144. }
  145. else if (243 < days && days <= 273)
  146. {
  147. days -= 243;
  148. months = 9;
  149. }
  150. else if (273 < days && days <= 304)
  151. {
  152. days -= 273;
  153. months = 10;
  154. }
  155. else if (304 < days && days <= 334)
  156. {
  157. days -= 304;
  158. months = 11;
  159. }
  160. else if (334 < days && days <= 365)
  161. {
  162. days -= 334;
  163. months = 12;
  164. }
  165. else if (days > 365)
  166. {
  167. days -= 364;
  168. years++;
  169. }
  170. }
  171. }
  172. cout << days << "." << months << "." << years << " " << hours << ":" << minutes << ":" << sec << " ";
  173. return 0;
  174. }
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement