请看看这个程式
#include "stdio.h"extern yearday(int year,int month,int day);
int monthday[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}};
main()
{
int y,m,d;
printf("please give year:");
scanf("%d \ n",&y);
printf("please give month:");
scanf("%d \ n",&m);
printf("please give day:");
scanf("%d \ n",&d);
printf("The day of the year is = %d.",yearday(y,m,d));
getch();
}
int yearday(int year,int month,int day)
{
int i,leap;
leap = year%4 == 0 && year%100 !=0 || year%400==0;
for(i=1;i<month;i++)
day+=monthday[leap][i];
return(day);
}
编译成功,运行不对,请各位帮忙也测试一下。
[[italic] 本帖最后由 stevending 于 2007-11-28 22:14 编辑 [/italic]]