为什么我输入2月的时候总是不显示天数,求大神解答!!!
int year,month;string a="";
Console.WriteLine("请输入年份和月份");
year = Convert.ToInt32(Console.ReadLine());
month = Convert.ToInt32(Console.ReadLine());
if (month <= 12 && month >= 1)
switch (month)
{
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12: a = "31"; break;
case 4:
case 6:
case 9:
case 11: a = "30"; break;
}
Console.WriteLine("{0}年{1}月有{2}天", year, month, a);
if (month >12||month <1)
Console.WriteLine("非法数据");
Console.ReadLine();
if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0)
{
switch (month)
{
case 2: a = "29"; break;
}
Console.WriteLine("{0}年{1}月有{2}天", year, month, a);
Console.ReadLine();
}