正文

6 (农历的算法,这个是最花费我心力的~~)2006-07-30 03:08:00

【评论】 【打印】 【字体: 】 本文链接:http://blog.pfan.cn/petibo/17008.html

分享到:

void Lunar(){int n;printf("1.Inquire the corresponding lunar day of the day you input\n");printf("2.Inquire the corresponding solar day of the day you input\n");printf("3.Exit\n");printf("Please input right number of the option which you want to inqiure:");scanf("%d",&n);switch (n){case 1:    solar_lunar();    break;case 2:    lunar_solar();    break;case 3:    screen();    break;default:    printf("Error!Please input the right character!!!\n");    Lunar();    break;}}void solar_lunar(){       int year,month,day,gan,zhi,animal;char yn;    Date *date;       input(solar_lunar);    if((y<1900)||(y>2100))        {        printf("Year out of range.\n");        solar_lunar();        }    date=solar2lunar(y,m,d);    year=date->year;       month=date->month;       day=date->day;    gan=(year-4)%10;animal=zhi=(year-4)%12;    if (LEAP)        printf("The corresponding lunar day is:\n%d/*%d/*%d,%s%s,Animal sign:%s\n",year,month,day,G[gan],Z[zhi],S[animal]);    else         printf("The corresponding lunar day is:\n%d/%d/%d,%s%s,Animal sign:%s\n",year,month,day,G[gan],Z[zhi],S[animal]);    printf("Continue(Y/N)?");scanf("%s",&yn);switch(yn){case  'y':   solar_lunar();   break;case  'n':   Lunar();   break;case  'Y':   solar_lunar();   break;case  'N':   Lunar();   break;default:  printf("Error!Please input the right character!!!\n");  Lunar();  break;}}void lunar_solar(){       int year,month,day,gan,zhi,animal;char yn;    Date *date;       input(lunar_solar);    if((y<1900)||(y>2100))        {        printf("Year out of range.\n");        lunar_solar();        }    printf("If this month is a lunar month(Y/N)?\n");    scanf("%s",&yn);    switch(yn)        {        case  'y':            LEAP=1;            break;        case  'n':            LEAP=0;            break;        case  'Y':            LEAP=1;            break;        case  'N':            LEAP=0;            break;        default:            printf("Error!Please input the right character!!!\n");            lunar_solar();            break;        }    date=lunar2solar(y,m,d);    year=date->year;    month=date->month;    day=date->day;    gan=(y-4)%10;animal=zhi=(y-4)%12;    printf("The corresponding solar day is:\n%d/%d/%d,%s%s,Animal sign:%s\n",year,month,day,G[gan],Z[zhi],S[animal]);    printf("Continue(Y/N)?");scanf("%s",&yn);switch(yn){case  'y':   lunar_solar();   break;case  'n':   Lunar();   break;case  'Y':   lunar_solar();   break;case  'N':   Lunar();   break;default:  printf("Error!Please input the right character!!!\n");  Lunar();  break;}}void jieqi(){int flag;static char *c[24]={"xiaohan","dahan","lichun","yushui","jinzhi","chunfen","qingming","guyu","lixia","xiaoman","mangzhong","xiazhi",                          "xiaoshu","dashu","liqiu","chushu","bailu","qiufen","hanlu","shuangjiang","lidong","xiaoxue","daxue","dongzhi"};input(jieqi);if((y<1900)||(y>2100))  {   printf("Year out of range.\n");  jieqi();  }flag=jieDate(y,m,d);if(!flag) printf("The day isn't a lunar festival.\n");elseprintf("The day is a lunar festival:%s.\n",c[flag-1]);Continue(jieqi);}

阅读(1210) | 评论(0)


版权声明:编程爱好者网站为此博客服务提供商,如本文牵涉到版权问题,编程爱好者网站不承担相关责任,如有版权问题请直接与本文作者联系解决。谢谢!

评论

暂无评论
您需要登录后才能评论,请 登录 或者 注册