世纪闰年%400==0

获得月份天数

http://www.nowcoder.com/questionTerminal/13aeae34f8ed4697960f7cfc80f9f7f6

import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int[] v1 = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
        int[] v2 = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
        while(sc.hasNext()){
            int y = sc.nextInt(), m = sc.nextInt();
            if(y%400 == 0 ||(y%4 == 0 && y %100 != 0)){
                System.out.println(v2[m]);
                continue;
            }
            System.out.println(v1[m]);
        }
    }
}
全部评论

相关推荐

不愿透露姓名的神秘牛友
昨天 18:35
简历上把1个月实习写成了3个月,会进行背调吗?
码农索隆:一个月有一个月的实习经历,三个月有三个月的实习经历
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
06-27 18:00
点赞 评论 收藏
分享
评论
2
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务