帮忙找下错!编译没错,运行不通过问题~试过多组数据,有些通过,有些则不行,请指点一下好吗?先谢了~~
帮忙找下错!编译没错,运行不通过问题~试过多组数据,有些通过,有些则不行,请指点一下好吗?先谢了~~year是年,
yearday是天数,
若year和yearday合理,
则*pmonth和*pday是计算得出的月和日,函数返回1;
否则,函数返回0。
int month_day(int year, int yearday, int *pmonth, int *pday)
{
int i=0,month=1,day,days=0,total_day,*day_tab;
int a[12]={31,28,31,30,31,30,31,31,30,31,30,31};
int b[12]={31,29,31,30,31,30,31,31,30,31,30,31};
if(year%4==0&&year%100!=0||year%400==0)
{
day_tab=b;
total_day=366;
}
else
{
day_tab=a;
total_day=365;
}
if(yearday<=total_day)
{
while(days<yearday)
{
days=days+*(day_tab+i);
i++;
month=i;
*pmonth=month;
if(day<yearday)
{day=yearday-days;
*pday=day;}
}
return (1);}
else
return (0);
}