判断闰年的程序可以根据不同的编程语言和需求进行编写。下面我将提供几种不同编程语言的闰年判断程序示例。
Java语言
```java
import java.util.Scanner;
public class LeapYearWithInput {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("请输入要判断的年份: ");
int year = scanner.nextInt();
boolean isLeapYear = (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0);
System.out.println(year + "年" + (isLeapYear ? "是" : "不是") + "闰年");
}
}
```
C语言
```c
include
int main() {
int year, leap;
printf("请输入一个年份: ");
scanf("%d", &year);
if (year % 4 == 0) {
if (year % 100 == 0) {
if (year % 400 == 0) leap = 1;
else leap = 0;
} else leap = 1;
} else leap = 0;
if (leap) printf("%d是闰年
", year);
else printf("%d不是闰年
", year);
return 0;
}
```
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}年不是闰年")
```
VB语言
```vb
Private Sub Form_Click()
For i = 2000 To 2099
If leapYear(i) 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
```
这些程序都遵循了闰年的判断规则:如果年份能被4整除且不能被100整除,或者能被400整除,则该年份是闰年。用户可以根据自己的需要选择合适的编程语言进行实现。