while(true)
{
Console.Write("\t\t\t欢迎进入!!!\n\t\t我来帮你判断是否是闰年\n请输入要判断的年份:\t");
long year = Convert.ToInt64(Console.ReadLine());
float N = year % 4, Y = year % 400;
if (year % 100 > 0)
{ Console.WriteLine(N > 0 ? "\t\t你好" + year + "年不是闰年!!!\n" : "\t\t你好" + year + "年是闰年!!!\n"); }
else
Console.WriteLine(Y > 0 ? "\t\t你好" + year + "年不是闰年!!!\n" : "\t\t你好" + year + "年是闰年!!!\n");
Console.WriteLine("是否退出? 退出请按 Y 不退出请按回车键!!");
string K= Console.ReadLine ();
if (K == "Y" || K == "y") { goto aa; }
}
aa: Console.WriteLine("欢迎再次光临!!!");
//满足闰年的条件:
// 能被4整除 并且不能被100整除
//能被400整除
Console.WriteLine(” 请输入年份:”);
int year = int.Parse(Console.ReadLine());
if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0))
{
Console.WriteLine(“这是一个闰年”);
}
else
{
Console.WriteLine(“这是一个平年”);
}
public class MyClass
{
public static bool IsLeapYear(int year)
{
return (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0);
}
public static void Main()
{
//调用
Console.WriteLine(IsLeapYear(2011)?"是闰年":"不是闰年");
}
}