using System; namespace ConsoleApplication1 { class Program { static bool CzySwieto(DateTime dt) { switch (dt.Month) { case 1: { if (dt.Day == 1 || dt.Day == 6) { return true; } break; } case 5: { if (dt.Day == 1 || dt.Day == 3) { return true; } break; } case 8: { if (dt.Day == 15) { return true; } break; } case 11: { if (dt.Day == 1 || dt.Day == 11) { return true; } break; } case 12: { if (dt.Day == 25 || dt.Day == 26) { return true; } break; } } if (dt.Month >= 3 || dt.Month <= 6) { //obliczanie Wielkanocy int a = dt.Year % 19; int b = (int)Math.Floor((decimal)(dt.Year / 100)); int c = dt.Year % 100; int d = (int)Math.Floor((decimal)(b / 4)); int e = b % 4; int f = (int)Math.Floor((decimal)((b + 8) / 25)); int g = (int)Math.Floor((decimal)((b - f + 1) / 3)); int h = (19 * a + b - d - g + 15) % 30; int i = (int)Math.Floor((decimal)(c / 4)); int k = c % 4; int l= (32+2*e+2*i-h-k)%7; int m = (int)Math.Floor((decimal)((a+11*h+22*l)/451)); int p = (h + l - 7 * m + 114) % 31; int dzien = p + 1; int miesiac = (int)Math.Floor((decimal)((h + l - 7 * m + 114) / 31)); DateTime Wielkanoc = new DateTime(dt.Year, miesiac, dzien); if (dt == Wielkanoc || dt == Wielkanoc.AddDays(1) || dt == Wielkanoc.AddDays(49) || dt == Wielkanoc.AddDays(60)) { return true; } } return false; } static void Main() { //Console.WriteLine(CzySwieto().ToString()); Console.Write("Czy 8 kwietnia 2012 bedzie wolne? - "); Console.WriteLine(CzySwieto(new DateTime(2012,4,8))); Console.Write("Czy 22 listopada 2010 bedzie wolne? - "); Console.WriteLine(CzySwieto(new DateTime(2010, 11, 22))); Console.Write("Czy 26 grudnia 2011 bedzie wolne? - "); Console.WriteLine(CzySwieto( new DateTime(2011, 12, 26))); Console.ReadKey(); } } }