fork(1) download
  1. using System;
  2.  
  3. namespace ConsoleApplication1
  4. {
  5. class Program
  6. {
  7. static bool CzySwieto(DateTime dt)
  8. {
  9.  
  10. switch (dt.Month)
  11. {
  12. case 1:
  13. {
  14. if (dt.Day == 1 || dt.Day == 6)
  15. {
  16. return true;
  17. }
  18. break;
  19. }
  20. case 5:
  21. {
  22. if (dt.Day == 1 || dt.Day == 3)
  23. {
  24. return true;
  25. }
  26. break;
  27. }
  28. case 8:
  29. {
  30. if (dt.Day == 15)
  31. {
  32. return true;
  33. }
  34. break;
  35. }
  36. case 11:
  37. {
  38. if (dt.Day == 1 || dt.Day == 11)
  39. {
  40. return true;
  41. }
  42. break;
  43. }
  44. case 12:
  45. {
  46. if (dt.Day == 25 || dt.Day == 26)
  47. {
  48. return true;
  49. }
  50. break;
  51. }
  52. }
  53.  
  54. if (dt.Month >= 3 || dt.Month <= 6)
  55. {
  56. //obliczanie Wielkanocy
  57. int a = dt.Year % 19;
  58. int b = (int)Math.Floor((decimal)(dt.Year / 100));
  59. int c = dt.Year % 100;
  60. int d = (int)Math.Floor((decimal)(b / 4));
  61. int e = b % 4;
  62. int f = (int)Math.Floor((decimal)((b + 8) / 25));
  63. int g = (int)Math.Floor((decimal)((b - f + 1) / 3));
  64. int h = (19 * a + b - d - g + 15) % 30;
  65. int i = (int)Math.Floor((decimal)(c / 4));
  66. int k = c % 4;
  67. int l= (32+2*e+2*i-h-k)%7;
  68. int m = (int)Math.Floor((decimal)((a+11*h+22*l)/451));
  69. int p = (h + l - 7 * m + 114) % 31;
  70. int dzien = p + 1;
  71. int miesiac = (int)Math.Floor((decimal)((h + l - 7 * m + 114) / 31));
  72.  
  73. DateTime Wielkanoc = new DateTime(dt.Year, miesiac, dzien);
  74.  
  75. if (dt == Wielkanoc || dt == Wielkanoc.AddDays(1) || dt == Wielkanoc.AddDays(49) || dt == Wielkanoc.AddDays(60))
  76. {
  77. return true;
  78. }
  79. }
  80. return false;
  81. }
  82.  
  83. static void Main()
  84. {
  85. //Console.WriteLine(CzySwieto().ToString());
  86.  
  87. Console.Write("Czy 8 kwietnia 2012 bedzie wolne? - ");
  88. Console.WriteLine(CzySwieto(new DateTime(2012,4,8)));
  89.  
  90. Console.Write("Czy 22 listopada 2010 bedzie wolne? - ");
  91. Console.WriteLine(CzySwieto(new DateTime(2010, 11, 22)));
  92.  
  93. Console.Write("Czy 26 grudnia 2011 bedzie wolne? - ");
  94. Console.WriteLine(CzySwieto( new DateTime(2011, 12, 26)));
  95.  
  96. Console.ReadKey();
  97. }
  98. }
  99. }
  100.  
Success #stdin #stdout 0.03s 24216KB
stdin
Standard input is empty
stdout
Czy 8 kwietnia 2012 bedzie wolne? - True
Czy 22 listopada 2010 bedzie wolne? - False
Czy 26 grudnia 2011 bedzie wolne? - True