判断闰年,四年一闰,百年不闰,四百年再闰。
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace 判断闰年 { class Program { static void Main(string[] args) { Console.Write("请输入要判断的年份:"); int year = Convert.ToInt32 (Console.ReadLine()); if (run(year)) { Console.Write("您输入的年份是闰年"); } else { Console.Write("您输入的不是闰年"); } Console.Read(); } static bool run (int year) { bool y; if(((year%4)==0)&((year%100)!=0)) { y = true; } else if ((year % 400) == 0) { y = true; } else { y = false; } return y; } } }