Đề bài
Xem bản dịchA 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.
Ràng buộc
1 ≤ year ≤ 9999.
Ví dụ
Đầu vào:
year = 2024
Kết quả mong đợi:
expected = True
Đầu vào:
long long year = 2024;
Kết quả mong đợi:
bool expected = true;
Đầu vào:
long year = 2024;
Kết quả mong đợi:
bool expected = true;
Giải thích
2024 is divisible by 4 and not by 100.
Đầu vào:
year = 2100
Kết quả mong đợi:
expected = False
Đầu vào:
long long year = 2100;
Kết quả mong đợi:
bool expected = false;
Đầu vào:
long year = 2100;
Kết quả mong đợi:
bool expected = false;
Giải thích
2100 is divisible by 100 but not by 400, so the century exception applies.
Tham khảo
Thử thách này đã được điều chỉnh cho CodeUtility. Hãy làm theo đề bài và các ràng buộc ở trên.