mashu3344 2017-05-02 09:43 采纳率: 50%
浏览 1299

万年历农历的程序代码中

/*****************************************************返回农历信息*****************************************************/
int get_lunar_info(int solar_year, int solar_month, Lunar_info l_info,Chinese_era *china_era)
{
int i;
int total;
int temp_num;
/
阳历1900年01月31日为农历1900年01月01日*/
total=get_solar_total(solar_year,solar_month)-30;//得出农历天数
china_era->era_day=total+40;
/*将13和14月作为下一年的1月和2月,便于确定Y年M月D日是星期几
蔡勒公式求星期几:W=[C/4]-2C+y+[y/4]+[13×(M+1)/5]+d-1*/
china_era->era_month=14;
for(i=1900;i=0;i++)
{
/*temp_num记录从1900到2050年闰年和平年的天数*/
temp_num=get_lunar_year_total(i);
total-=temp_num;
/*累计月*/
china_era->era_month+=12;
}
l_info->lunar_year=i;
if(total {
total+=temp_num;
/*减年*/
l_info->lunar_year--;
china_era->era_month-=12;
}
/*1864年为农历甲子年*/
china_era->era_year=l_info->lunar_year-1864;
/*返回是否存在闰月*/
l_info->leap_month=get_leap_month(l_info->lunar_year);
l_info->leap_flag=0;
for(i=1;i0;i++)
{
if (l_info->leap_month>0&&i==(l_info->leap_month+1)&&l_info->leap_flag==0)
{
--i;
temp_num=get_leap_month_day(l_info->lunar_year);
/*存在闰月*/
l_info->leap_flag=1;
}
else
temp_num=get_lunar_month_total(l_info->lunar_year, i);
if (l_info->leap_flag==1&&i==(l_info->leap_month+1))
l_info->leap_flag=0;
total-=temp_num;
if (l_info->leap_flag==0)
china_era->era_month++;
}
if(total==0&&l_info->leap_month>0&&i==l_info->leap_month+1)
if(l_info->leap_flag==1)
l_info->leap_flag=0;
else
{
l_info->leap_flag=1;
--i;
--china_era->era_month;
}
if(total {
total+=temp_num;
--i;
--china_era->era_month;
}
l_info->lunar_month=i;
l_info->lunar_day=total+1;
if (l_info->leap_flag==0)
l_info->current_mday=get_lunar_month_total(l_info->lunar_year,l_info->lunar_month);
else
l_info->current_mday=get_leap_month_day(l_info->lunar_year);
return 0;
哪位大神能解释一下这段代码中的这些句式代表什么意思吗。是怎样实现的。
紧急求助!!!

  • 写回答

1条回答 默认 最新

  • threenewbee 2017-05-02 09:58
    关注

    这个涉及农历中闰月的计算,昨天回答过你了,给你百度百科链接,里面有闰月的算法

    评论

报告相同问题?

悬赏问题

  • ¥15 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号