#ifndef LEAPYEAR_INCLUDED
#define LEAPYEAR_INCLUDED
class LeapYear
{
public:
bool IsLeapYear(int year);
};
#endif
#include "leapyear.hpp"
auto Or = [](bool a,bool b)->bool{ return a||b; };
auto And = [](bool a,bool b)->bool{ return a&&b; };
auto Not = [](bool a)->bool{ return !a; };
auto Aliquot = [](int dividend,int divisor){return dividend%divisor == 0;};
bool LeapYear::IsLeapYear(int year)
{
auto aliquotby4 = Aliquot(year,4);
auto notaliquotby100 = Not(Aliquot(year,100));
auto aliquotby400 = Aliquot(year,400);
auto leapyear = Or(And(aliquotby4,notaliquotby100),aliquotby400);
return leapyear;
}
时间: 2024-11-10 01:19:11