2个回答
展开全部
private const int inityear = 2000, initmonth = 1, initday = 1, initweek = 6;
static int GetYearDays(int year)
{
int daynum = 0;
for (int i = inityear; i < year; i++)
{
if ((i % 4 == 0 && i % 100 != 0) || i % 400 == 0)
{
daynum += 366;
}
else
{
daynum += 365;
}
}
return daynum;
}
static int GetMonthDays(int year,int month)
{
int daynum = 0;
for (int i = initmonth; i < month; i++)
{
switch (i)
{
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
daynum += 31;
break;
case 4:
case 6:
case 9:
case 11:
daynum += 30;
break;
case 2:
if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0)
{
daynum += 29;
}
else
{
daynum += 28;
}
break;
}
}
return daynum;
}
剩下的自己做
static int GetYearDays(int year)
{
int daynum = 0;
for (int i = inityear; i < year; i++)
{
if ((i % 4 == 0 && i % 100 != 0) || i % 400 == 0)
{
daynum += 366;
}
else
{
daynum += 365;
}
}
return daynum;
}
static int GetMonthDays(int year,int month)
{
int daynum = 0;
for (int i = initmonth; i < month; i++)
{
switch (i)
{
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
daynum += 31;
break;
case 4:
case 6:
case 9:
case 11:
daynum += 30;
break;
case 2:
if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0)
{
daynum += 29;
}
else
{
daynum += 28;
}
break;
}
}
return daynum;
}
剩下的自己做
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询