Problema
Mostra traduzioneA year divisible by 4 is a leap year unless it is also divisible by 100. Years divisible by 400 are leap years despite that exception. Apply this arithmetic rule to every allowed input year.
Implement leap_year(year).
Input
year: The year to check.
Output
Return true for a leap year and false otherwise.
Vincoli
1 ≤ year ≤ 9999.
Esempi
Input:
year = 2024
Output atteso:
expected = True
Input:
long long year = 2024;
Output atteso:
bool expected = true;
Input:
long year = 2024;
Output atteso:
bool expected = true;
Spiegazione
2024 is divisible by 4 and not by 100.
Input:
year = 2100
Output atteso:
expected = False
Input:
long long year = 2100;
Output atteso:
bool expected = false;
Input:
long year = 2100;
Output atteso:
bool expected = false;
Spiegazione
2100 is divisible by 100 but not by 400, so the century exception applies.
Riferimenti
Questa sfida è adattata per CodeUtility. Segui la traccia e i vincoli sopra.