#作业要求:闰年的判定(符合下面两个条件之一):
1.年份能够被400整除.(2000)
2.年份能够被4整除但不能被100整除.(2008)
让用户输入一个年份,如果是润年,则输出true,如果不是,则输出false。
作业代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("请输入年份");
int year = Convert.ToInt32(Console.ReadLine());
bool b = year % 400 == 0 || (year % 4 == 0 && year % 100 != 0);
Console.WriteLine(b);
Console.ReadKey();
}
}
}
网友评论