正在加载图片...
例8-4void month_day(int year, int yearday, int* pmonth,int* pday) int k, leap;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),1;[*建立润年判别条件leap*leap = (year%4== 0 && year%100 != 0) Il year%400 == 0;for(k = 1; yearday > tab[leap][k]; k++)yearday = yearday-tab [leap][k];*pmonth=k;daymonth*pday = yearday;371input year and yearday: 2000 612000-3-1pmonthpday例8-4 void month_day ( int year, int yearday, int* pmonth, int* pday) { int k, leap; 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 */ leap = (year%4 == 0 && year%100 != 0) || year%400 == 0; for ( k = 1; yearday > tab[leap][k]; k++) yearday = yearday-tab [leap][k]; *pmonth = k; *pday = yearday; } input year and yearday: 2000 61 2000-3-1 month day pmonth pday 3 1
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有