把一个数组写的函数改成用指针写!
static char daytab[2][13]={{0,31,28,31,30,31,30,31,31,30,31,30,31},{0,31,28,31,30,31,30,31,31,30,31,30,31}};
int day_of_year(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+=daytab[leap][i];
return day;
}
void month_day(int year,int yearday,int *pmonth,int *pday)
{
int i,leap;
leap= year%4 == 0 && year %%100 !=0 || year%400=0;
for (i=1;yearday>daytab[leap][i];i++)
yearday-=daytab[leap][i];
*pmonth=i;
*pday=yearday;
}
两 个函数都是用数组写的,改成用指针的,然后再用一个main把他们编程一个完整的程序。
[ 本帖最后由 成功了吗 于 2010-4-11 14:39 编辑 ]