mirror of
https://bitbucket.org/Mattrixwv/projecteulercpp.git
synced 2025-12-06 17:13:59 -05:00
Reworked to better match other languages
This commit is contained in:
@@ -36,7 +36,6 @@ A leap year occurs on any year evenly divisible by 4, but not on a century unles
|
||||
#include <cinttypes>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user