Add tags

Add tags to the following comment

一応、条件は満たしているかと思います。 こんな感じでどうでしょうか?

 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));
    }
}

Add tags

The input will be splited to tags with space.

Index

Feed

Other

Link

Pathtraq

loading...