Advertisement
Guest User

Untitled

a guest
Jan 24th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.53 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdio>
  3. #include <math.h>
  4. using namespace std;
  5. void text(int line)
  6. {
  7. if (line == 1)
  8. {
  9. printf("%21s", "January");
  10. printf("%23s", "February");
  11. printf("%23s", "March");
  12. cout << endl;
  13. return;
  14. }
  15. if (line == 2)
  16. {
  17. printf("%21s", "April");
  18. printf("%23s", "May");
  19. printf("%23s", "June");
  20. cout << endl;
  21. return;
  22. }
  23. if (line == 3)
  24. {
  25. printf("%21s", "Jule");
  26. printf("%23s", "August");
  27. printf("%23s", "September");
  28. cout << endl;
  29. return;
  30. }
  31. printf("%21s", "October");
  32. printf("%23s", "November");
  33. printf("%23s", "December");
  34. cout << endl;
  35. }
  36. bool LY(int year)
  37. {
  38. return ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0));
  39. }
  40. int AoD(int year)
  41. {
  42. return 365 + LY(year);
  43. }
  44. int AoDM(int year, int month)
  45. {
  46. if ((month >= 1 && month <= 7 && month % 2 == 1)
  47. || (month >= 8 && month % 2 == 0 && month <= 12))
  48. return 31;
  49. if (month == 2)
  50. {
  51. if (LY(year))
  52. return 29;
  53. return 28;
  54. }
  55. return 30;
  56. }
  57. int AoDANY(int year, int month, int day)
  58. {
  59. int AoDANY = day;
  60. for(int i = 1; i < month; i++)
  61. {
  62. AoDANY += AoDM(year, i);
  63. }
  64. return AoDANY;
  65. }
  66. int AoDABOE(int day, int month, int year)
  67. {
  68. int AoDABOE = AoDANY(year, month, day);
  69. int i = 1;
  70. for(int i = 1; i < year; i++)
  71. {
  72. AoDABOE += AoD(i);
  73. }
  74. return AoDABOE;
  75. }
  76. int AoDB2D(int year1, int month1, int day1, int year2, int month2, int day2)
  77. {
  78. int AoDABOEBD1 = AoDABOE(year1, month1, day1);
  79. int AoDABOEBD2 = AoDABOE(year2, month2, day2);
  80. return (AoDABOEBD2 - AoDABOEBD1);
  81. }
  82. int DoW(int year1, int month1, int day1, int WD, int year2, int month2, int day2)
  83. {
  84. int q;
  85. q = AoDB2D(year1, month1, day1, year2, month2, day2);
  86. return (q % 7 + WD) % 7 + 7 * ((q % 7 + WD) % 7 == 0);
  87. }
  88. int main()
  89. {
  90. int year;
  91. int line;
  92. cin >> year;
  93. for(int line = 1; line <= 4; line++)
  94. {
  95. text(line);
  96. }
  97. int month;
  98. int a = 1;
  99. int b = 1;
  100. for(int week = 1; week <= 6; week++)
  101. {
  102. if (week == 1)
  103. {
  104. for (month = (line - 1)*3; month <= 3 * line; month++)
  105. {
  106. int FMD = DoW(17, 1, 2017, 2, 1, month, year);
  107. for (a = 1, b = 1; a <= 7 && b <= 7; a++, b++)
  108. {
  109. while (b < FMD)
  110. {
  111. printf("%3s", " ");
  112. b++;
  113. }
  114.  
  115.  
  116. printf("%3i", a);
  117. }
  118. cout << " ";
  119. }
  120. cout << endl;
  121. }
  122. else
  123. {
  124. while (month <= line * 3)
  125. {
  126. month = 3 * line - 2;
  127. int c = week * 7 - DoW(17, 1, 2017, 2, 1, month, year) + 2;
  128. int d = 0;
  129. for (int d = 0; d < 7 && c + d <= AoDM(month, year); d++)
  130. {
  131. printf("%3i", c + d);
  132. }
  133. while (c + d >= AoDM(month, year) && d < 7)
  134. {
  135. printf("%3s", " ");
  136. d += 1;
  137. }
  138. cout << " ";
  139. }
  140. cout << endl;
  141. }
  142. }
  143. return 0;
  144. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement