用数组编的看看吧!
#include<stdio.h>
int main(void)
{
int year,mouth,day;
int day_of_day(int year,int mouth,int day);
printf("请输入年月日:\n");
scanf("%d%d%d",&year,&mouth,&day);
printf("是一年中的第:%d",day_of_day(year,mouth,day));
return 0;
}
int day_of_day(int year,int mouth,int day)
{
int k,leap;
int tab[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}
};
leap=(year%4==0&&year%100!=0||year%400==0);
for(k=1;k<mouth;k++)
day=day+tab[leap][k];
return day;
}