#include <head.h>
#define PRINT_YEAR 1
#define PRINT_MONTH 2
// 周日 0
// 周一 1
// ...
// 周六 6
int getWeekdayByYearday(int iY, int iM, int iD)
{
int iWeekDay = -1;
if (1 == iM || 2 == iM) {
iM += 12;
iY--;
}
iWeekDay = (iD + 1 + 2 * iM + 3 * (iM + 1) / 5 + iY + iY / 4 - iY / 100 + iY / 400) % 7;
return iWeekDay;
}
//判断某年是平年(365天)还是闰年(366天)
int getmonthofday(int year, int month){
int day = 0;
switch (month){
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
day = 31;
break;
case 4:
case 6:
case 9:
case 11:
day = 30;
break;
case 2:
if((year % 4 == 0) && (year % 100 != 0) || (year % 400 == 0)){
day = 29;
}else{
c语言编写万年历
最新推荐文章于 2023-11-22 00:08:28 发布