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 % == )
{
if (year % == )
{
if (year % == )
{
flag = true;
}
}
else
{
flag = true;
}
}
return flag;
}
}

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

using System;

public static class Kata
{
public static bool IsLeapYear(int year)
{ return DateTime.IsLeapYear(year);
}
}
上一篇:接口自动化 基于python+Testlink+Jenkins实现的接口自动化测试框架[V2.0改进版]


下一篇:16.C语言中数据类型的本质含义是:表示一个内存格子的长度和解析方法。