欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

读入一个表示年份的整数,判断这一年是否是闰年。

程序员文章站 2022-07-07 09:47:27
...
import java.util.Scanner;
public class t4 {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
	    int y=sc.nextInt();
	    if((y%400==0)||(y%4==0&&y%100!=0))
	    	System.out.println("是闰年");
	    else
	    {
	    	System.out.println("不是闰年");
	    }
	}
}