From d5e7b0adb0ec6e614b0e6cf067f18e3b37f75183 Mon Sep 17 00:00:00 2001 From: AlternateWalls <71268229+AlternateWalls@users.noreply.github.com> Date: Tue, 5 Oct 2021 17:44:15 -0400 Subject: [PATCH] Create easter.cpp --- others/easter.cpp | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 others/easter.cpp diff --git a/others/easter.cpp b/others/easter.cpp new file mode 100644 index 000000000..b75663f03 --- /dev/null +++ b/others/easter.cpp @@ -0,0 +1,36 @@ +// You can read more about the reason behind the algorithm itself here: +// https://en.wikipedia.org/wiki/Date_of_Easter + +class easter +{ + public: + static void FindEaster(int y) + { + if (y > 1582) + { + // Calculations + int a = y % 19; + int b = y / 100; + int c = y % 100; + int d = b / 4; + int e = b % 4; + int f = (b + 8) / 25; + int g = (b - f + 1) / 3; + int h = (19 * a + b - d - g + 15) % 30; + int i = c / 4; + int k = c % 4; + int r = (32 + 2 * e + 2 * i - h - k) % 7; + int m = (a + 11 * h + 22 * r) / 451; + int n = (h + r - 7 * m + 114) / 31; + int p = (h + r - 7 * m + 114) % 31; + + // Print date + cout << "Easter in " + y + " falls on " + n + "/" + + (p + 1) + "."); + } + else + { + return; + } + } +}