1
0
mirror of https://github.com/renbaoshuo/202401-programming-assignments.git synced 2024-12-16 15:44:39 +00:00
202401-programming-assignments/【实践课外】4.循环结构1/7-7 输出闰年.c

28 lines
468 B
C

#include <stdio.h>
int main() {
int year;
scanf("%d", &year);
if (2000 < year && year <= 2100) {
int count = 0;
for (int i = 2001; i <= year; i++) {
if ((i % 4 == 0 && i % 100 != 0) || i % 400 == 0) {
printf("%d\n", i);
count++;
}
}
if (count == 0) {
printf("None\n");
}
} else {
printf("Invalid year!\n");
}
return 0;
}