diff --git a/src/Problems/Problem19.cpp b/src/Problems/Problem19.cpp index ef66e5b..da6a17b 100644 --- a/src/Problems/Problem19.cpp +++ b/src/Problems/Problem19.cpp @@ -36,7 +36,6 @@ A leap year occurs on any year evenly divisible by 4, but not on a century unles #include #include #include -#include "Stopwatch.hpp" #include "Problems/Problem19.hpp" @@ -68,20 +67,26 @@ Problem19::DAYS Problem19::getDay(unsigned int month, unsigned int day, unsigned } //Add the correct number of days for every month while(currentMonth < month){ - //31 day months - if(currentMonth == 2){ - if(isLeapYear(currentYear)){ - numDays += 29; - } - else{ - numDays += 28; - } - } - else if((currentMonth == 1) || (currentMonth == 3) || (currentMonth == 5) || (currentMonth == 7) || (currentMonth == 8) || (currentMonth == 10) || (currentMonth == 12)){ - numDays += 31; - } - else{ - numDays += 30; + switch(currentMonth){ + case 1: + case 3: + case 5: + case 7: + case 8: + case 10: + case 12: numDays += 31; break; + case 4: + case 6: + case 9: + case 11: numDays += 30; break; + case 2: + if(isLeapYear(currentYear)){ + numDays += 29; + } + else{ + numDays += 28; + } + break; } ++currentMonth; }