[原创]天数与日期的转换
*/ --------------------------------------------------------------------------------------*/ 出自: 编程中国 http://www.bc-cn.net
*/ 作者: 李飞龙 QQ:81516156
*/ 时间: 2007-9-18 编程论坛首发
*/ 声明: 尊重作者劳动,转载请保留本段文字
*/ --------------------------------------------------------------------------------------
main()
{static int day_tab[][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}};
printf("%d\n",day_of_year(day_tab,2007,100));
}
day_of_year(day_tab,year,yearday,pmonth,pday)
int year,yearday,*pmonth,*pday;
{
int i,leap,q;
leap=(year%4==0&&year%100||year%400==0);
for(i=1;yearday>(q=*(*(day_tab+leap)+i));i++)
yearday-=q;
*pmonth=i;
*pday=yearday;
}