1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5 using System.Threading.Tasks;
6
7 namespace ConsoleApp1
8 {
9 class Program
10 {
11 static void Main(string[] args)
12 {
13 bool a = IsRun(2004);
14 Console.WriteLine("the year is {0} leap year ", a);
15 Console.ReadKey();
16 }
17 /// <summary>
18 /// 判断year是不是闰年的函数
19 /// </summary>
20 /// <param name="year"></param>
21 /// <returns></returns>
22 public static bool IsRun(int year)
23 {
24 bool b = (year % 400 == 0) || (year % 4 == 0 && year % 100 != 0);
25 ///普通情况除以4余数为零则为闰年
26 ///有个特殊情况是是100的倍数,但是不是400的倍数,也不是闰年;
27 ///比如1700年、1800年、1900年、2100年不是闰年
28 return b;
29 }
30 }
31 }