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 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 arduino控制ps2手柄一直报错
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 求chat4.0解答一道线性规划题,用lingo编程运行,第一问要求写出数学模型和lingo语言编程模型,第二问第三问解答就行,我的ddl要到了谁来求了
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题
  • ¥15 Visual Studio问题
  • ¥20 求一个html代码,有偿
  • ¥100 关于使用MATLAB中copularnd函数的问题