Problème
Afficher la traductionA 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.
Contraintes
1 ≤ year ≤ 9999.
Exemples
Entrée :
year = 2024
Sortie attendue :
expected = True
Entrée :
long long year = 2024;
Sortie attendue :
bool expected = true;
Entrée :
long year = 2024;
Sortie attendue :
bool expected = true;
Explication
2024 is divisible by 4 and not by 100.
Entrée :
year = 2100
Sortie attendue :
expected = False
Entrée :
long long year = 2100;
Sortie attendue :
bool expected = false;
Entrée :
long year = 2100;
Sortie attendue :
bool expected = false;
Explication
2100 is divisible by 100 but not by 400, so the century exception applies.
Références
Ce défi a été adapté pour CodeUtility. Suivez l'énoncé et les contraintes ci-dessus.