请用户输年份,再输入月份,输出该月的天数.
int day = 0;
switch (mon)
{
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12: day = 31;
break;
case 2:
if (year % 4 == 0)
{
day = 29;
}
else
{
day = 28;
}
break;
default:
day=30;
break;
}
Console.WriteLine("{0}年的{1}月有{2}天", year, mon, day);
Console.ReadKey();
网友评论