Fácil 0 resueltos 0% de aceptación

Leap Year

Check whether a year follows the Gregorian leap-year rule.

A 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.

Restricciones

1 ≤ year ≤ 9999.

Ejemplos

Ejemplo 1
Entrada:
year = 2024

Salida esperada:
expected = True
Entrada:
long long year = 2024;

Salida esperada:
bool expected = true;
Entrada:
long year = 2024;

Salida esperada:
bool expected = true;

Explicación

2024 is divisible by 4 and not by 100.

Ejemplo 2
Entrada:
year = 2100

Salida esperada:
expected = False
Entrada:
long long year = 2100;

Salida esperada:
bool expected = false;
Entrada:
long year = 2100;

Salida esperada:
bool expected = false;

Explicación

2100 is divisible by 100 but not by 400, so the century exception applies.

Referencias

Este reto está adaptado para CodeUtility. Sigue el enunciado y las restricciones indicadas arriba.

Aprende de otros

Soluciones de la comunidad

Aún no hay soluciones publicadas. Resuelve este reto para compartir la primera.