判断闰年的程序可以根据不同的编程语言有不同的实现方法。以下是几种常见编程语言的闰年判断程序示例:
VB编程
```vb
Private Sub Form_Click()
For i = 2000 To 2099
If leapYear(i) = True Then
Print i
End If
Next i
End Sub
Private Function leapYear(ByVal y As Integer) As Boolean
' 自定义判断闰年函数
If (y Mod 4 = 0 And y Mod 100 <> 0) Or (y Mod 400 = 0) Then
' 判断闰年的条件
leapYear = True
Else
leapYear = False
End If
End Function
```
Java编程
```java
import java.util.Scanner;
class LeapYear {
public static void main(String[] args) {
System.out.println("请输入年份:");
int year = scanner.nextInt();
if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0) {
System.out.println(year + "是闰年");
} else {
System.out.println(year + "不是闰年");
}
}
}
```
Python编程
```python
def is_leap_year(year):
if (year % 4 == 0 and year % 100 != 0) or year % 400 == 0:
return True
else:
return False
year = int(input("请输入年份:"))
if is_leap_year(year):
print(f"{year}年是闰年")
else:
print(f"{year}年不是闰年")
```
C语言编程
```c
include
int main() {
int year;
printf("请输入一个年份:\n");
scanf("%d", &year);
if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0) {
printf("%d年是闰年\n", year);
} else {
printf("%d年不是闰年\n", year);
}
return 0;
}
```
C++编程
```cpp
include
bool isLeapYear(int year) {
if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0) {
return true;
} else {
return false;
}
}
int main() {
int year;
std::cout << "请输入一个年份:" << std::endl;
std::cin >> year;
if (isLeapYear(year)) {
std::cout << year << "年是闰年" << std::endl;
} else {
std::cout << year << "年不是闰年" << std::endl;
}
return 0;
}
```
JavaScript编程
```javascript
function isLeapYear(year) {
return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
}
const year = parseInt(prompt("请输入年份:"));
if (isLeapYear(year)) {
console.log(`${year}年是闰年`);
} else {
console.log(`${year}年不是闰年`);
}
```
以上示例代码分别用VB、Java、Python、C、C++和JavaScript编程语言实现了判断闰年的功能。你可以根据自己的需求选择合适的编程语言进行实现。