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

28 lines
468 B
C
Raw Normal View History

2024-10-25 08:43:54 +00:00
#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;
}