如何调用..
如何把int day_of_year 函数里的值调回主函数啊!新手来的,我们上的那书讲得很简单,求推荐好书加习题..# include <stdio.h>
int day_of_year (int x,int y,int z);
int main (void)
{
int year,month,day;
printf("请输入你要计算的年月日:");
scanf("%d%d%d",&year,&month,&day);
day_of_year (day,month,year);
printf("day=%d\n",day);
return 0;
}
int day_of_year (int x,int y,int z)
{
int leap,k;
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=(z%4==0 && z%100!=0 ||z%400==0);
for(k=1;k<y;k++)
x=x+tab[leap][k];
return x;
}
[ 本帖最后由 无之小刀 于 2011-11-4 17:32 编辑 ]