zoukankan      html  css  js  c++  java
  • 判断年份是否为闰年及非法数据的处理

    一、问题描述

       判断输入的年份是否为闰年

    二、功能实现

      在输入栏中输入年份,点击确认按钮,若年份为闰年,则显示“您输入的年份是闰年”,如年份非闰年,则显示“您输入的年份不是闰年”

    三、代码实现

    <html>
    <head>
    <script type="text/javascript">
    function test(){
    var input1=document.getElementById('input1').value;
    
    if input1%400==0
    {
          windows.alert("您所输入的时间为闰年")
    }
    else if (input1%100!=0&&input1%4==0)
    {
         windows.alert("您所输入的时间为闰年")
    }
    else
    {
         windows.alert("您所输入的时间不是闰年")
    }
    }
    
    
    </script>
    </head>
    
    <body>
    <input type="text" id="input1" value ="输入1" /><br/>
    <input type="button" onclick="test()" value="确定" />
    </body>
    </html>

       四、测试用例

    测试用例 输出结果
    1900 非闰年
    2005   非闰年
    3 非闰年
    400 闰年
    1804 闰年
    2000 闰年
    1987 非闰年
    1400 非闰年
    1576 闰年
  • 相关阅读:
    bfs,队列
    Wannafly挑战赛22 A计数器(裴蜀定理 gcd)
    素数筛模板
    HDU
    HDU
    控制精度-----直接截取,不需四舍五入
    jstl下载与配置
    B. Treasure Hunt
    动态数组vector
    Manacher算法
  • 原文地址:https://www.cnblogs.com/Lucasleiva/p/4396516.html
Copyright © 2011-2022 走看看