你要努力了哦!这些问题没什么含金量的,但是还是帮你解答了吧!
int[] arrMoth = new int[12] { 31, 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
int year = DateTime.Now.Year;
if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0)
{
arrMoth[1] = 29;
}
else
{
arrMoth[1] = 28;
}
int moth = DateTime.Now.Month - 1;//2
for (int i = 0; i < arrMoth.Length; i++)
{
if (moth == i)
{
Console.WriteLine("现在是今年的{0}月,这个月有{1}天", i + 1, arrMoth[i]);
}
} |