Leap Years

Description:

In this kata you should simply determine, whether a given year is a leap year or not. In case you don‘t know the rules, here they are:

  • years divisible by 4 are leap years
  • but years divisible by 100 are no leap years
  • but years divisible by 400 are leap years

Additional Notes:

  • Only valid years (positive integers) will be tested, so you don‘t have to validate them

Examples can be found in the test fixture.

using System;

public static class Kata
{
  public static bool IsLeapYear(int year)
  {
    // TODO
    bool flag = false;
            if (year % 4 == 0)
            {
                if (year % 100 == 0)
                {
                    if (year % 400 == 0)
                    {
                        flag = true;
                    }
                }
                else
                {
                    flag = true;
                }
            }
            return flag;
  }
}

其他人的解法:物体吐槽了,.net自带了相关的函数

using System;

public static class Kata
{
  public static bool IsLeapYear(int year)
  {

     return DateTime.IsLeapYear(year);
  }
}
时间: 2024-08-16 08:48:17

Leap Years的相关文章

HDU 3455 Leap Frog(线性DP)

Problem Description Jack and Jill play a game called "Leap Frog" in which they alternate turns jumping over each other. Both Jack and Jill can jump a maximum horizontal distance of 10 units in any single jump. You are given a list of valid posit

【VR】Leap Motion 官网文档 HandModel(手部模型)

前言: 本系列译文是为迎合Unity VR的热潮与大家的学习需要,推出的针对Unity方向的Leap Motion官方文档中英对照翻译. 本篇为第六篇 <HandModel(手部模型)> ,该类主要用于连接控制器和手部模型,以及处理手臂.肘部.手掌.手指的位置和角度等信息. Handmodel is the base class for all the other hand scripts. If you are creating your own hands and need a custo

五大科技巨头VR/AR专利报告,Magic Leap以22.6%领跑

在十月份发布的<VR/AR专利技术深度分析报告>指出,VR.AR行业的专利多被佳能.索尼.微软.谷歌等科技巨头"包养",但是并没有对这部分进行详细分析.近日,风投公司CB Insights发布了一份报告,详细分析了美国五大IT巨头(谷歌.苹果.Facebook.亚马逊.微软)在不同科技细分领域的专利表现. 总体分析:从五大公司的专利总数上微软是冠军,近七年来微软申请的专利总数达到了16840个,其次是谷歌的14596个专利,第三名是苹果13420个,之后是亚马逊5186个和

HTC Vive 与Leap Motion 出现位置错误的问题

Leap Motion已经支持VR, 但是官方没有支持HTC Vive的例子. 按照官方的文档, 其实是有问题的: https://developer.leapmotion.com/documentation/unity/unity/Unity_Custom_Rig.html Add the LeapVRTemporalWarping script component to the LeapSpace component you just created. Double check that t

【VR】Leap Motion 官网文档 手型资源

前言: Leap Motion的官网文档已经有不少的热心网友参与了翻译,但没有覆盖官网文档的全部. 为迎合Unity VR的热潮与大家的学习需要,推出的针对Unity方向的官方文档翻译系列. 第三篇 <手型资源> 介绍了Leap Motion为Unity提供的资源包种的手型预设体资源. Hand Assets  手型资源 The Leap Motion core assets for Unity include a number of pre-made hand prefabs assets.

Unity3D中使用Leap Motion进行手势控制

Leap Motion作为一款手势识别设备,相比于Kniect,优点在于精确度. 在我的毕业设计<场景漫游器>的开发中,Leap Motion的手势控制作为重要的一个环节.以此,谈谈开发中使用Leap Motion进行手势识别的实现方式以及需要注意的地方. 一.对Leap Motion的能力进行评估 在设定手势之前,我们必须知道Leap Motion能做到哪种程度,以免在设定方案之后发现很难实现.这个评估依靠实际对设备的使用体验,主要从三个方面: 1.Leap Motion提供的可视化的手势识

Linux leap second 问题导致的应用程序慢

leap second 是指Linux系统自动调整系统时间,这通常会发生在某个月的月末,很可能是6月和12月的月底,当leap second发生的时候可能会导致应用程序(Java)很繁忙,从而导致响应很慢. 若如下命令返回中有leap=01,那么就意味着将会有leap second发生 ntpq -c "lassoc" -c "mrv &1 &999 leap,srcadr,stratum" 若如下命令返回中有"no leap second

【VR】Leap Motion 官网文档 脚本参考(目录)

前言: 本系列译文是为迎合Unity VR的热潮与大家的学习需要,推出的针对Unity方向的Leap Motion官方文档中英对照翻译. 本篇第四篇 <脚本参考> 以目录链接的形式列出了Leap Motion为Unity提供的核心资源包中所包含的脚本定义的类. 关于每个类的详细内容后续献上,敬请期待. 英文原文网址:https://developer.leapmotion.com/documentation/unity/unity/Unity_Classes.html 译文首发&持续更

大新闻!Magic Leap造假,HoloLens即将入华商用

昨天微软搞了大新闻,Terry和Alexi到了深圳,在WinHEC大会上宣布了2017上半年HoloLens正式入华商用. 而唯一竞争对手Magic Leap今天也被曝光其设备造假,各大科技媒体纷纷报道,部分相关报道如下: [新浪科技]Magic Leap被揭底:实际效果不如微软AR 演示视频只是特效 [腾讯科技]Magic Leap被揭穿:所有成果展示全是特效视频 其中新浪科技报道里说“甚至还不如微软的HoloLens”,我只想说小编你牛逼你研发一个啊.你渣浪找不出一个能干的人,给微软的实验室