//输入年月日
Console.Write("请输入年:");
int year = Convert.ToInt32(Console.ReadLine());
Console.Write("请输入月:");
int month = Convert.ToInt32(Console.ReadLine());
Console.Write("请输入日:");
int day = Convert.ToInt32(Console.ReadLine());
if ((year % 4 == 0 && year % 100 != 0) || (year % 100 == 0 && year % 400 == 0))
{
if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12)
{
if (day >= 1 && day <= 31)
{
Console.WriteLine("正确");
}
else
{
Console.WriteLine("错误");
}
}
else if (month == 4 || month == 6 || month == 9 || month == 11)
{
if (day >= 1 && day <= 30)
{
Console.WriteLine("正确");
}
else
{
Console.WriteLine("错误");
}
}
else
{
if (day >= 1 && day <= 29)
{
Console.WriteLine("正确");
}
else
{
Console.WriteLine("错误");
}
}
}
else
{
if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12)
{
if (day >= 1 && day <= 31)
{
Console.WriteLine("正确");
}
else
{
Console.WriteLine("错误");
}
}
else if (month == 4 || month == 6 || month == 9 || month == 11)
{
if (day >= 1 && day <= 30)
{
Console.WriteLine("正确");
}
else
{
Console.WriteLine("错误");
}
}
else
{
if (day >= 1 && day <= 28)
{
Console.WriteLine("正确");
}
else
{
Console.WriteLine("错误");
}
}
}
Console.ReadLine();