horiuchi #5338(2008/01/16 02:12 GMT) [ Java ] Rating1/1=1.00
一応、条件は満たしているかと思います。 こんな感じでどうでしょうか?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
public class Sample124 { public static boolean isLeepYear(int year) { if (!isDividedBy4(year)) return false; String sYear = String.valueOf(year); if (sYear.endsWith("00")) { return isDividedBy4(Integer.parseInt(sYear.substring(0, sYear.length() - 2))); } return true; } private static boolean isDividedBy4(int num) { return (num & 3) == 0; } public static void main(String[] args) { System.out.println("1900:" + isLeepYear(1900)); System.out.println("2000:" + isLeepYear(2000)); System.out.println("2008:" + isLeepYear(2008)); System.out.println("2100:" + isLeepYear(2100)); } }
Rating1/1=1.00-0+
1 reply [ reply ]
horiuchi
#5338()
[
Java
]
Rating1/1=1.00
一応、条件は満たしているかと思います。 こんな感じでどうでしょうか?
Rating1/1=1.00-0+
1 reply [ reply ]