上传文件至 /

This commit is contained in:
2026-03-20 09:32:14 +08:00
parent 4ae70d5c2e
commit 5d108b8dba
4 changed files with 126 additions and 0 deletions

27
LeapYear.java Normal file
View File

@@ -0,0 +1,27 @@
public class LeapYear {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.print("请输入2000~3000内的年数!");
int year = scan.nextInt();
scan.close();
if (year < 2000 || year > 3000) {
System.out.println("请输入2000~3000内的年数!");
return;
}
boolean isLeap = false;
if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)) {
isLeap = true;
}
if (isLeap) {
System.out.println(year + "年是闰年");
} else {
System.out.println(year + "年不是闰年");
}
}
}