1118. 一月有多少天


判断是否为闰年

class Solution {
     public int numberOfDays(int Y, int M) {
        int arr[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
        if(is_Leap(Y)&&M==2)
        return 29;
        else return arr[M];
    }
    public static boolean is_Leap(int i) {
        if(i%4==0&&i%100!=0|| i%400==0) {
            return true;
        }
        return false;
    }
}

猜你喜欢

转载自www.cnblogs.com/cznczai/p/11183038.html
今日推荐