编译结果不对,显示答案错误了
#include<stdio.h>
int countday(int year,int month,int day,int yearday);
int main(void)
{
int year,month,day,yearday;
scanf("%d%d%d",&year,&month,&day);
countday(year,month,day,yearday);
printf("%d",yearday);
return 0;
}
int countday(int year,int month,int day,int yearday)
{
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},
};
int k,leap;
leap=(year%4==0&&year%100!=0)||year%400==0;
yearday=0;
for(k=1;k<=month;k++){
yearday=yearday+tab[leap][k];
}
yearday=yearday+day;
return yearday;
}