C语言问题,高手请进

2024-12-27 16:56:24
推荐回答(3个)
回答1:

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
我会详细给你讲解

回答2:

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}};

回答3:

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;
}