📄 任意年.c
字号:
#include <stdio.h>
#define uchar unsigned char
#define uint unsigned int
uchar week(uint year,uchar month,uchar day);
code uchar WEEK_BIAO_P[]={4,0,0,3,5,1,3,6,2,4,0,2}; //平年月星期表
code uchar WEEK_BIAO_R[]={3,6,0,3,5,1,3,6,2,4,0,2}; //闰年月星期表
void main(void)
{
uchar a;
uchar month,day;
uint year;
year=2004;month=6;day=9;
while(1)
{
a=week(year,month,day);
}
}
/*********************************************************************
将2004年代入。得(其中百年=20,年=04)
2004某日星期几=(百年%4*5天+年+年/4+月星期表+日+2天)%7
入口参数:year(年),month(月),day(日)
出口参数:return_week(星期几)
影响变量:无
调用函数:无
占用空间:6个单元RAM
*********************************************************************8*/
uchar week(uint year,uchar month,uchar day)
{
uchar return_week;
uchar centry;
centry=year/100;
year=year%100;
//if(
return_week=( centry%4*5 + year +year/4 +WEEK_BIAO_P[month-1] + day +2 )%7;
return return_week;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -