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);}

评论