day_of_year
练习(5-9):用指针而不是索引重写例程。
static char daytab[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}
};
/* day_of_year: set day of year from month and day */
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;
}
我可能只是累了,没有思考,但实际上如何创建一个带有指针的多维数组?
我可能会弄清楚该函数的其余部分,但我无法正确使用语法。