//1.闰年(1)年份能被4整除,但不能被100整除;(2)能被400整除。
Scanner input = new Scanner(System.in);
while (true) {
System.out.println("请输入年份:");
int year = input.nextInt();//年份
if ((year % 4 == 0 & year % 100 != 0) || year % 400 == 0) {
System.out.println(year + "是闰年");
} else {
System.out.println(year + "是平年");
}
}
JAVA判断当前年份是否是闰年
最新推荐文章于 2023-05-28 22:49:08 发布