#作業(yè)要求
讓用戶輸入一個年份,如果是潤年,則輸出true,如果不是,則輸出false.
#程序
namespace ConsoleApplication1
{
? ? class Program
? ? {
? ? ? ? static void Main(string[] args)
? ? ? ? {
? ? ? ? ? ? Console.WriteLine("請輸入年份");
? ? ? ? ? ? string str_year=Console.ReadLine();
? ? ? ? ? ?
? ? ? ? ? ? int year=Convert.ToInt32(str_year);
? ? ? ? ? ? bool b = year % 400 == 0 || (year % 4 == 0 && year % 100 != 0);
? ? ? ? ? ? Console.WriteLine("你輸入的年份是{0},此年份是不是閏年{1}",year,b);
? ? ? ? ? ? Console.ReadKey();
? ? ? ? }
? ? }
}
#效果

圖片發(fā)自簡書App