万年历算法分析(公历阴历农历)

万年历算法分析(公历阴历农历)

ID:10760259

大小:56.00 KB

页数:15页

时间:2018-07-08

万年历算法分析(公历阴历农历)_第1页
万年历算法分析(公历阴历农历)_第2页
万年历算法分析(公历阴历农历)_第3页
万年历算法分析(公历阴历农历)_第4页
万年历算法分析(公历阴历农历)_第5页
资源描述:

《万年历算法分析(公历阴历农历)》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库

1、万年历算法一、 阳历算法具体算法见函数Void get_solar_day_date(void),这样阳历日历的星期排法就确定了。表1:月份 1 2 3 4 5 6 7 8 9 10 11 12 闰年 31 29 31 30 31 30 31 31 30 31 30 31 非闰年 31 28 31 30 31 30 31 31 30 31 30 31 变量定义:Public:Unsigned int temp_total_day;Unsigned char gc_solar_calendar_year;Unsigned char gc_solar_calen

2、dar_month;Unsigned char gc_solar_calendar_date;Unsigned char gc_lunar_calendar_year;Unsigned char gc_lunar_calendar_month;Unsigned char gc_lunar_calendar_date;Unsigned char start_day_of_week;说明:函数get_solar_day_date(void)的输入变量:gc_solar_calendar_year和gc_solar_calendar_month输出变量:start

3、_day_of_week和temp_total_dayVoid get_solar_day_date(void){unsigned char temp01;/*------calculate what day is the day of the current month and year. Mon~Sun?---*//*条件初始化二次,减少运算数据量. temp_total_day 是int型变量*/start_day_of_week = 2; temp_total_day = 0;calculate_temp = 1;if(gc_solar_calend

4、ar_year > 99){start_day_of_week = 6;calculate_temp = 100;}for(temp01 = calculate_temp; temp01

5、ar_month;temp01++){ switch(temp01){case 1,3,5,7,8,10,12: start_day_of_week +=3;temp_total_day +=31;break;case 2: if(((gc_solar_calendar_year%4) == 0)&&(gc_solar_calendar_year != 200)){start_day_of_week +=1; temp_total_day +=29;}else {start_day_of_week +=0;temp_total_day +=28;} brea

6、k;case 4,6,9,11: start_day_of_week +=2; temp_total_day +=30; break;}}start_day_of_week %=7;/*-end of calculate what day is the day(Mon~Sun?) and total day --*/}二、 阴历算法200年需要200 × 2 = 400个字节,构成阴历压缩数据表lunar_calendar_month_table[]如下:const char lunar_calendar_month_table[]={ //从阴历年1900

7、年到2100年/*the total day of each month pointer *//* from 1901~2100*//* (0110)110000001001 (0110)leap month,110000001001 lunar month total day: 1:29 0:30*/0x00,0x04,0xad,0x08,0x5a,0x01,0xd5,0x54,0xb4,0x09,0x64,0x05,0x59,0x45, 0x95,0x0a,0xa6,0x04,0x55,0x24,0xad,0x08,0x5a,0x62,0xda,0x04

8、,0xb4,0x05, 0xb4,0x55,0x52

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。