计算一年中的第几天
include leap year
int dayOfYear(int year, int month, int day) { int months[13] = {0,31,30,28,31,30,31,31,30,31,30,31}, i, days = 0; if( (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)) // is leap year months[2] = 29; for(i = 1; i < month; i++) days += months[i]; days += day; return days; }