代码实现
public class LeapYear {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.println("请输入一个年份:");
long year = scan.nextLong();
if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0) {
System.out.println(year + "是闰年");
} else {
System.out.println(year + "不是闰年");
}
}
}
这是一个Java程序,用于检查输入的年份是否为闰年。用户输入年份,程序通过判断年份能被4整除但不能被100整除,或者能被400整除的条件来确定年份是否为闰年。
4万+

被折叠的 条评论
为什么被折叠?



