单片机万年历阴阳历c语言,单片机阴历阳历c算法万年历.pdf

51 单片机万年历优化算法源程序

Public:

Unsigned int temp_total_day;

Unsigned char gc_solar_calendar_year;

Unsigned char gc_solar_calendar_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 ；

Void 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_calendar_year > 99)

{start_day_of_week = 6;calculate_temp = 100;}

for(temp01 = calculate_temp; temp01

{ if(temp01%4 == 0){start_day_of_week +=2;temp_total_day += 366; }

else {start_day_of_week +=1;temp_total_day += 365;}}

for(temp01 = 1;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;} break;

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[]={ // 从阴历年 190

• 0
点赞
• 0
收藏
• 0
评论
10-13
05-10
09-30 1万+
05-22 1777
07-04 1万+
11-27 1607
08-03
05-03
10-10 4034
01-02 1311
05-23 845

“相关推荐”对你有帮助么？

• 非常没帮助
• 没帮助
• 一般
• 有帮助
• 非常有帮助

1.余额是钱包充值的虚拟货币，按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载，可以购买VIP、C币套餐、付费专栏及课程。