package cn.myAlgorithm;
/**
*
* <p>Title: Leap</p>
* <p>Description:判断某年是否为闰年
* 闰年:能被4和400整除,但其中能被100整除的年份不算
* </p>
* @author Chill Lyn
* @date 2019年9月22日
*/
public class Leap {
public static void main(String[] args) {
System.out.println(isLeap(1900));
System.out.println(isLeap(2000));
System.out.println(isLeap(2004));
System.out.println(isLeap(2005));
}
public static boolean isLeap(int year) {
if (year % 4 == 0) {
if (year % 100 == 0 && year % 400 != 0) {
return false;
}
return true;
}
return false;
}
}
结果:
false
true
true
false