Kodewick
开始学 →
入门←→0 / 50

判断闰年

#004入门year % 400 == 0约 4 分钟

闰年的规则:能被 4 整除、但不能被 100 整除的是闰年;能被 400 整除的也是闰年。比如 2024、2000 是闰年,2023、1900 不是。写 is_leap(year):是闰年返回 true,不是返回 false。

示例
is_leap(2024)→True
is_leap(2023)→False
is_leap(2000)→True
函数bool is_leap(int year)
main.c
#include <stdbool.h>

bool is_leap(int year) {
    // 在这里写:按闰年的规则返回 true 或 false
    return false;
}
Ctrl + Enter 也能运行
结果

写好了先点「运行」试试示例,没问题再点「提交」。