static int dayTab[2][13]= {{0,31,28,31,30,31,30,31,31,0,3,30,31},
{0,31,29,31,30,31,30,31,31,0,3,30,31}};
int DayOfYear(int year,int month,int day)
{
int i,leap;
leap=((year%4==0)&&(year%100!=0))||(year%400==0);
for(i=1;i
day=day+dayTab[leap][i];
}
return day;
调用DayOfYear函数即可
有不懂的地方加100190523
我会详细给你讲解
static int dayTab[2][13]= {{0,31,28,31,30,31,30,31,31,0,3,30,31},
{0,31,29,31,30,31,30,31,31,0,3,30,31}};
static int dayTab[2][13]= {{0,31,28,31,30,31,30,31,31,0,3,30,31},
{0,31,29,31,30,31,30,31,31,0,3,30,31}};
int day(int year,int month,int day)
{
int i,leap;
leap=((year%4==0)&&(year%100!=0))||(year%400==0);
for(i=1;i
day=day+dayTab[leap][i];
}
return day;
}