请用户输入年份,输入月份,输出该月份天数

时间:2024-10-09 07:46:00
namespace 练习1
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.Write("请输入年份:");
            int year = (());
            ("请输入月份");
            int month = (());
            switch (month)
            {
                case 1:
                case 3:
                case 5:
                case 7:
                case 8:
                case 10:
                case 12:
                    ("31天");
                    break;
                case 2:
                    if (year % 400 == 0 || (year % 4 == 0 && year % 100 != 0))
                    {
                        //是润年
                        ("29天");
                    }
                    else
                    {   //不是润年
                        ("28天");
                    }
                    break;
                default:
                    break;
            }
            ();
        }
    }
}