标签:
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:
Additional Notes:
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); } }
标签:
原文地址:http://www.cnblogs.com/chucklu/p/4622911.html