Ocena użytkownikóww: ***** / 0
Nadesłany przez DarekS, 05 stycznia 2017 11:33
Kod przedstawiony poniżej przedstawia główną część rozwiązania problemu.
Pobierz pełne rozwiązanie.Jeżeli nie odpowiada Ci sposób formatowania kodu przez autora skorzystaj z pretty printer'a i dostosuj go automatycznie do siebie.
EasterDay.cs:
//Obliczanie daty Wielkanocy - metoda Meeusa/Jonesa/Butchera
//www.algorytm.org
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
namespace Rextester
{
public class Program
{
//Dzien wielkanocy - metoda Meeusa/Jonesa/Butchera
static public DateTime getEaster(DateTime dt)
{
int year = dt.Year;
int day, month;
int a, b, c, d, e, f, g, h, i, k, l, m, p;
a = year % 19;
b = (int) year / 100;
c = year % 100;
d = (int) b / 4;
e = b % 4;
f = (int) ((b + 8) / 25);
g = (int) ((b - f + 1) / 3);
h = (19 * a + b - d - g + 15) % 30;
i = (int) c / 4;
k = c % 4;
l = (32 + 2 * e + 2 * i - h - k) % 7;
m = (int) ((a + 11 * h + 22 * l) / 451);
p = (h + l - 7 * m + 114) % 31;
day = p + 1;
month = (int) ((h + l - 7 * m + 114) / 31);
return new DateTime(year, month, day);
}
public static void Main(string[] args)
{
DateTime dt = getEaster(DateTime.Now);
Console.WriteLine(dt.ToString());
}
}
}