int Day(int year, int month, int day)
{
int i;int days = 0;
int months[12] = {31,0,31,30,31,30,31,31,30,31,30,31};
//判断某年是否是闰年,看它是否满足一下2个条件之一(不可能同时满足)
if( (year % 400 == 0) || ( (year % 4 == 0) && ( year % 100 != 0) ) )//400的倍数或者能整除4而不能整除100
months[1] = 29;
else
months[1] = 28;
for(i = 1; i < month; i++)
days += months[i];
days += day;
return days;
}
c语言计算这是一年中的第几天
最新推荐文章于 2024-09-27 15:44:33 发布