Leap Years
2015-07-05 20:14
239 查看
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); } }
相关文章推荐
- SQL SERVER公用表表达式CTE详解
- Reorder List 链表操作
- Java的Interfaces与Callbacks
- hdu 2732 Leapin' Lizards
- java api 里实现好的一个缓存类
- linux程序设计——用信号量进行同步(第十二章)
- linux安装jdk
- C#高级编程三十四天----数组作为参数
- 测试Mysql的最大连接数
- 原码,反码,补码
- MD5超强加密
- 排序 - 快速排序
- 遗传算法
- 排序 - 快速排序
- 语句的应用
- 类什么时候被加载
- Android 水波纹点击效果(Ripple Effect)
- JavaBean
- scss 在mac下编译
- A题 hdu 1235 统计同成绩学生人数