/****************************************************************************** * This program computes leap years. * * Copyright © 2020 Richard Lesh. All rights reserved. *****************************************************************************/ #undef NDEBUG #include #include #include #include std::locale utf8loc(std::locale(), new std::codecvt_utf8); using namespace std; /****************************************************************************** * Returns true if a year is a leap year. *****************************************************************************/ bool is_leap_year(int Y) noexcept { return Y % 4 == 0 && Y % 100 != 0 || Y % 400 == 0; } int main(int argc, char **argv) { setlocale(LC_ALL, "en_US.UTF-8"); wcout.imbue(utf8loc); wcin.imbue(utf8loc); wcout << L"1900 is " << (is_leap_year(1900) ? L"" : L"NOT ") << L"a leap year." << endl; wcout << L"2000 is " << (is_leap_year(2000) ? L"" : L"NOT ") << L"a leap year." << endl; wcout << L"2012 is " << (is_leap_year(2012) ? L"" : L"NOT ") << L"a leap year." << endl; wcout << L"2019 is " << (is_leap_year(2019) ? L"" : L"NOT ") << L"a leap year." << endl; return 0; }