猿问

大神帮我看看这个求年月日是该年中的第几天,计算结果是4399232,小白找不出来,谢谢大家!!!

#include<stdio.h>

 static char daytab[2][13]={{0,31,28,31,30,31,30,31,31,30,31,30,31},{0,31,29,31,30,31,30,31,31,30,31,30,31}};


 int day_of_year(int year,int month,int day)

 {

  int i,leap;

  leap = year%4 == 0 && year%100 != 0 || year%400 == 0;

  for(i=1;i<month;i++)

  {

  day += daytab[leap][i];

}

return day;

 }

  int main()

  {

  int year,month,day;

  scanf("%d\n",&year);

  scanf("%d\n",&month);

  scanf("%d",&day);

  day_of_year(year,month,day);

  printf("这个是一年中的第%d天",day_of_year);

  return 0;

  }


慕雪3212274
浏览 1534回答 1
微课
1回答
随时随地看视频慕课网APP
我要回答