โจทย์
ดูฉบับแปล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.
เงื่อนไข
1 ≤ year ≤ 9999.
ตัวอย่าง
ตัวอย่างที่ 1
อินพุต:
year = 2024
ผลลัพธ์ที่คาดหวัง:
expected = True
อินพุต:
long long year = 2024;
ผลลัพธ์ที่คาดหวัง:
bool expected = true;
อินพุต:
long year = 2024;
ผลลัพธ์ที่คาดหวัง:
bool expected = true;
คำอธิบาย
2024 is divisible by 4 and not by 100.
ตัวอย่างที่ 2
อินพุต:
year = 2100
ผลลัพธ์ที่คาดหวัง:
expected = False
อินพุต:
long long year = 2100;
ผลลัพธ์ที่คาดหวัง:
bool expected = false;
อินพุต:
long year = 2100;
ผลลัพธ์ที่คาดหวัง:
bool expected = false;
คำอธิบาย
2100 is divisible by 100 but not by 400, so the century exception applies.
แหล่งอ้างอิง
โจทย์นี้ปรับให้เหมาะกับ CodeUtility กรุณาทำตามคำชี้แจงและข้อจำกัดด้านบน