static void Main(string[] args)
{
while (true) //输入某年某月某日判断是该年第多少天
{
int year, mooth, day;
Console.Write("请输入年份:");
year=int.Parse( Console.ReadLine());
if (year > 0 && year <= 9999)
{
Console.Write("请输入月份:");
mooth = int.Parse(Console.ReadLine());
if (mooth >= 1 && mooth <= 12)
{
Console.Write("请输入日期:");
day = int.Parse(Console.ReadLine());
if((mooth==1||mooth==3||mooth==5||mooth==7||mooth==8||mooth==10||mooth==12)&&(day>=1 && day<=31))
{
Console.WriteLine("这是"+year+"年"+mooth+"月"+day+"日");
}
else if ((mooth == 4 || mooth == 6 || mooth == 9 || mooth == 11) && (day >= 1 && day <= 30))
{
Console.WriteLine("这是" + year + "年" + mooth + "月" + day + "日");
}
else if (mooth == 2 && (year % 400 == 0 || (year % 100 != 0 && year % 4 == 0)) && (day >= 1 && day <= 29))
{
Console.WriteLine("这是" + year + "年" + mooth + "月" + day + "日");
}
else if (mooth == 2 && (!(year % 400 == 0 || (year % 100 != 0 && year % 4 == 0))) && (day >= 1 && day <= 28))
{
Console.WriteLine("这是" + year + "年" + mooth + "月" + day + "日");
}
else
{
Console.WriteLine("输入日期有误");
}
}
else
{
Console.WriteLine("输入月有误");
}
}
else
{
Console.WriteLine("输入年有误");
}
![]()