mirror of
https://github.com/TheAlgorithms/C-Plus-Plus.git
synced 2026-11-03 06:14:41 +08:00
Update easter.cpp
This commit is contained in:
@@ -25,9 +25,9 @@
|
||||
*/
|
||||
class EasterYearMonthDay {
|
||||
public:
|
||||
int year; ///< year Easter is on
|
||||
int month; ///< month Easter is on
|
||||
int day; ///< day Easter is on
|
||||
uint64_t year; ///< year Easter is on
|
||||
uint64_t month; ///< month Easter is on
|
||||
uint64_t day; ///< day Easter is on
|
||||
|
||||
EasterYearMonthDay(int newYear, int newMonth, int newDay) {
|
||||
year = newYear; // Assigns year to class
|
||||
@@ -45,22 +45,22 @@ class EasterYearMonthDay {
|
||||
*/
|
||||
EasterYearMonthDay findEaster(int y) {
|
||||
if (y > 1582) {
|
||||
int a = y % 19; // Year's location on Metonic Calendar
|
||||
int b = y / 100; // Century index
|
||||
int c = y % 100;
|
||||
int d = b / 4;
|
||||
int e = b % 4; // Takes into account leap years
|
||||
int f = (b + 8) / 25;
|
||||
int g = (b - f + 1) / 3;
|
||||
int h = (19 * a + b - d - g + 15) %
|
||||
uint64_t a = y % 19; // Year's location on Metonic Calendar
|
||||
uint64_t b = y / 100; // Century index
|
||||
uint64_t c = y % 100;
|
||||
uint64_t d = b / 4;
|
||||
uint64_t e = b % 4; // Takes into account leap years
|
||||
uint64_t f = (b + 8) / 25;
|
||||
uint64_t g = (b - f + 1) / 3;
|
||||
uint64_t h = (19 * a + b - d - g + 15) %
|
||||
30; // Days from Mar. 21st until the full moon
|
||||
int i = c / 4;
|
||||
int k = c % 4;
|
||||
int r = (32 + 2 * e + 2 * i - h - k) %
|
||||
uint64_t i = c / 4;
|
||||
uint64_t k = c % 4;
|
||||
uint64_t r = (32 + 2 * e + 2 * i - h - k) %
|
||||
7; // The number of days from Paschal full moon to next Sunday
|
||||
int m = (a + 11 * h + 22 * r) / 451;
|
||||
int n = (h + r - 7 * m + 114) / 31; // Month of Easter
|
||||
int p = (h + r - 7 * m + 114) % 31; // p + 1 is the day of Easter
|
||||
uint64_t m = (a + 11 * h + 22 * r) / 451;
|
||||
uint64_t n = (h + r - 7 * m + 114) / 31; // Month of Easter
|
||||
uint64_t p = (h + r - 7 * m + 114) % 31; // p + 1 is the day of Easter
|
||||
|
||||
// Assign values
|
||||
EasterYearMonthDay date(
|
||||
|
||||
Reference in New Issue
Block a user