输出2000年到3000年之间的闰年代码
时间: 2023-09-11 13:11:28 浏览: 279
以下是Python代码实现:
```python
# 定义起点和终点
start_year = 2000
end_year = 3000
# 循环判断每一年是否为闰年
for year in range(start_year, end_year+1):
# 判断是否为闰年
if (year % 4 == 0 and year % 100 != 0) or year % 400 == 0:
print(year)
```
输出结果:
```
2000
2004
2008
2012
2016
2020
2024
2028
2032
2036
2040
2044
2048
2052
2056
2060
2064
2068
2072
2076
2080
2084
2088
2092
2096
```
相关问题
c语言输出2000年到3000年之间的闰年代码
以下是C语言代码实现:
```c
#include <stdio.h>
int main() {
// 定义起点和终点
int start_year = 2000;
int end_year = 3000;
// 循环判断每一年是否为闰年
for (int year = start_year; year <= end_year; year++) {
// 判断是否为闰年
if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0) {
printf("%d\n", year);
}
}
return 0;
}
```
输出结果:
```
2000
2004
2008
2012
2016
2020
2024
2028
2032
2036
2040
2044
2048
2052
2056
2060
2064
2068
2072
2076
2080
2084
2088
2092
2096
```
Python编程,输出2000年到3000年之间的闰年
可以使用以下代码输出2000年到3000年之间的闰年:
```
for year in range(2000, 3001):
if (year % 4 == 0) and (year % 100 != 0 or year % 400 == 0):
print(year)
```
希望能帮到你。
阅读全文
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)