?? 任意年.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
入口參數(shù):year(年),month(月),day(日)
出口參數(shù):return_week(星期幾)
影響變量:無
調(diào)用函數(shù):無
占用空間: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;
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -