Advertisement
Guest User

Untitled

a guest
May 21st, 2018
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <locale.h>
  4.  
  5. int month(int s, int n)
  6. {
  7. int i;
  8. if (s == 0)
  9. s = 7;
  10. printf("_____________________\n");
  11. printf(" Пн Вт Ср Чт Пт Сб Вс\n");
  12. printf("_____________________\n");
  13. for (i = 1; i < s; i++)
  14. printf(" ");
  15. for (i = 1; i <= n; i++)
  16. {
  17. printf("%3d",i);
  18. if ((s + i) % 7 == 1)
  19. printf("\n");
  20. }
  21. printf("\n\n");
  22. s = (s + n) % 7;
  23. if (s == 0)
  24. s = 7;
  25. return s;
  26. }
  27.  
  28. int main()
  29. {
  30. int g, Feb, b, m, y;
  31. setlocale(LC_ALL, "Rus");
  32. printf("Введите год: ");
  33. scanf("%d", &g);
  34. if (g % 4 ==0)
  35. Feb = 29;
  36. else
  37. Feb = 28;
  38. if (g % 100 ==0)
  39. Feb = 28;
  40. if (g % 400 ==0)
  41. Feb = 29;
  42. y=g-1;
  43. m=11;
  44. b=(1 + y + y / 4 - y / 100 + y / 400 + (31 * m) / 12) % 7 ;
  45.  
  46. printf("Январь \n");
  47. b = month(b, 31);
  48. printf("Февраль \n");
  49. b = month(b, Feb);
  50. printf("Март \n");
  51. b = month(b, 31);
  52. printf("Апрель \n");
  53. b = month(b, 30);
  54. printf("Май \n");
  55. b = month(b, 31);
  56. printf("Июнь \n");
  57. b = month(b, 30);
  58. printf("Июль \n");
  59. b = month(b, 31);
  60. printf("Август \n");
  61. b = month(b, 31);
  62. printf("Сентябрь \n");
  63. b = month(b, 30);
  64. printf("Октябрь \n");
  65. b = month(b, 31);
  66. printf("Ноябрь \n");
  67. b = month(b, 30);
  68. printf("Декабрь \n");
  69. b = month(b, 31);
  70. return 0;
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement