zoukankan      html  css  js  c++  java
  • 判断输入的年份是闰年还是平年!!!

    package com.hp.cn1;

    import java.util.Scanner;

    //年份能被4整除闰年
    //年份能被100整除不是闰年
    //年份能被400整除闰年
    public class Task2 {
        public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
            System.out.println("---->请输入年份");
            int year  = sc.nextInt();
            System.out.println("你输入的年份是"+year);
            
            if(year % 100 == 0) {
                if(year % 400 == 0) {
                    System.out.println(year + "是闰年");
                }else {
                    System.out.println(year + "不是闰年");
                }
            }else {
                if(year % 4 == 0) {
                    System.out.println(year + "是闰年");
                }else {
                    System.out.println(year + "不是闰年");
                }
            }
        }
    }

  • 相关阅读:
    用导数解决逗逼初三数学二次函数图像题
    NOIP 2014 pj & tg
    BZOJ 1004
    双参数Bellman-ford带队列优化类似于背包问题的递推
    emu1
    無題
    15 day 1代碼
    javascript quine
    线段树的总结
    Watering the Fields(irrigation)
  • 原文地址:https://www.cnblogs.com/wjwz/p/14131861.html
Copyright © 2011-2022 走看看