C语言题目:给出年月日,计算该日是该年的第几天

2022-07-30 社会 39阅读
#include 
int day_of_year(int year,int month, int day)
{
int monthDays[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
int i;
for(i=0;iday+=monthDays[i];
if(year%4==0&&year%100!=0||year%400==0)
{
if (month >2)
day+=1;
}
return day;
}
int main()
{
int day;
day=day_of_year(2013,5,23);
printf("%d\n",day);
return 0;
}
声明:你问我答网所有作品(图文、音视频)均由用户自行上传分享,仅供网友学习交流。若您的权利被侵害,请联系fangmu6661024@163.com