判断闰年

代码中使用1表示闰年,0表示不是闰年

public class leap_years {

    public static void main(String[] args) {
        int year = Integer.parseInt(args[ 0]);
        int leap;
        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==1)
            System.out.println(year+"年是闰年");
        else
            System.out.println(year+"年不是闰年");
    }
}
1、然后运行为配置

image

 

2、输入年份

image

3、然后点击下面的运行

image

posted @ 2014-04-26 10:10  时间淡无痕  阅读(226)  评论(0编辑  收藏  举报