c语言八字码,C语言之测八字 - 课件/论文下载 - 电子技术论坛 - 广受欢迎的专业电子论坛!...

tinue;

}

if( total_day> get_lunar_month_total(lunar_year,lunar_month ) )

{

total_day=total_day-get_lunar_month_total(lunar_year,lunar_month);

lunar_month++;

}

else

{

lunar_day=total_day;

break;

}

}

}

}//以上代码来自互联网!

main()

{

int solar_year;

char solar_month;

char solar_day;

int time;

int A,P,Q,B,D;//A为年份,D为月份

int e,f,g,h,i,j,M,N,E,F,Y,W,R,T,t,S,b,m;

printf("                                    测八字\n");

printf("生辰八字或者说八字,其实是周易术语四柱的另一种说法。\n");

printf("四柱是指人出生的时间、即年、月、日、时。\n");

printf("在人用天干和地支各出一字相配合分别来表示年、月、日、时。\n");

printf("如甲子年、丙申月、辛丑日、壬寅时等,包含了一个人出生时的天体运行的基本状态。\n");

printf("每柱两字,四柱共八字,所以算命又称“测八字”。\n\n");

printf("依照天干、地支沂涵阴阳五行属性之相生、相克的关系,推测人的体咎祸福。\n");

printf("一、(特别说明)时辰的输入方式:\n");

printf("例如:\n");

printf("     1、出生时辰在(2:00~2:59)之间,则均以2计入即输入2。其他区间类同;\n");

printf("     2、若出生时辰在(0:00~0:59)之间,则输入24;\n");

printf("     3、默认输入时辰为24小时制。\n");

printf("二、输入举例:\n");

printf("     1、生辰为1993年阳历4月8日早上6点15,则输入:1993/4/8/6\n");

printf("     2、生辰为1991年阳历8月16日下午16点59,则输入:1991/8/16/16\n");

printf("\n\n");

printf("请输入您的出生年月日及时辰:");

scanf("%d/%d/%d/%d",&solar_year,&solar_month,&solar_day,&time);

solar_lunar(solar_year,solar_month,solar_day);

printf("您的农历生日为:%u年农历%u月%u日\n",lunar_year,lunar_month,lunar_day);

A=solar_year;//A为阳历年份,

F=(int)solar_month;//F为阳历月份,

E=(int)solar_day;//E为阳历日数,

S=(int)time;

R=(int)lunar_year;//R为农历年份,

D=(int)lunar_month;//D为农历月份,

for(P=R%10;P>10;R=R/10);

for(Q=R%12;Q>12;R=R/12);

printf("您的生辰八字为:");

switch(P)

{

case 4:printf("甲");break;

case 5:printf("乙");break;

case 6:printf("丙");break;

case 7:printf("丁");break;

case 8:printf("戊");break;

case 9:printf("己");break;

case 0:printf("庚");break;

case 1:printf("辛");break;

case 2:printf("壬");break;

case 3:printf("癸");break;

}

switch(Q)

{

case 4:printf("子,");break;

case 5:printf("丑,");break;

case 6:printf("寅,");break;

case 7:printf("卯,");break;

case 8:printf("辰,");break;

case 9:printf("巳,");break;

case 10:printf("午,");break;

case 11:printf("未,");break;

case 0:printf("申,");break;

case 1:printf("酉,");break;

case 2:printf("戌,");break;

case 3:printf("亥,");break;

}

if(P==4||P==9)

B=1;

if(P==5||P==0)

B=2;

if(P==6||P==1)

B=3;

if(P==7||P==2)

B=4;

if(P==8||P==3)

B=5;

b=F+1;

switch(B)

{case 1:

switch(b)

{case 3:printf("丙寅,");break;

case 4:printf("丁卯,");break;

case 5:printf("戊辰,");break;

case 6:printf("己巳,");break;

case 7:printf("庚午,");break;

case 8:printf("辛未,");break;

case 9:printf("壬申,");break;

case 10:printf("癸酉,");break;

case 11:printf("甲戌,");break;

case 12:printf("乙亥,");break;

case 1:printf("甲子,");break;

case 2:printf("乙丑,");break;

default:printf("您输入的月份有误!");

};break;

case 2:

switch(b)

{case 3:printf("戊寅,");break;

case 4:printf("己卯,");break;

case 5:printf("庚辰,");break;

case 6:printf("辛巳,");break;

case 7:printf("壬午,");break;

case 8:printf("癸未,");break;

case 9:printf("甲申,");break;

case 10:printf("乙酉,");break;

case 11:printf("丙戌,");break;

case 12:printf("丁亥,");break;

case 1:printf("丙子,");break;

case 2:printf("丁丑,");break;

default:printf("您输入的月份有误!");

};break;

case 3:

switch(b)

{case 3:printf("庚寅,");break;

case 4:printf("辛卯,");break;

case 5:printf("壬辰,");break;

case 6:printf("癸巳,");break;

case 7:printf("申午,");break;

case 8:printf("乙未,");break;

case 9:printf("丙申,");break;

case 10:printf("丁酉,");break;

case 11:printf("戊戌,");break;

case 12:printf("己亥,");break;

case 1:printf("戊子,");break;

case 2:printf("己丑,");break;

default:printf("您输入的月份有误!");

};break;

case 4:

switch(b)

{case 3:printf("壬寅,");break;

case 4:printf("癸卯,");break;

case 5:printf("甲辰,");break;

case 6:printf("乙巳,");break;

case 7:printf("丙午,");break;

case 8:printf("丁未,");break;

case 9:printf("戊申,");break;

case 10:printf("己酉,");break;

case 11:printf("庚戌,");break;

case 12:printf("辛亥,");break;

case 1:printf("庚子,");break;

case 2:printf("辛丑,");break;

default:printf("您输入的月份有误!");

}break;

case 5:

switch(b)

{case 3:printf("甲寅,");break;

case 4:printf("乙卯,");break;

case 5:printf("丙辰,");break;

case 6:printf("丁巳,");break;

case 7:printf("戊午,");break;

case 8:printf("己未,");break;

case 9:printf("庚申,");break;

case 10:printf("辛酉,");break;

case 11:printf("壬戌,");break;

case 12:printf("癸亥,");break;

case 1:printf("壬子,");break;

case 2:printf("癸丑,");break;

default:printf("您输入的月份有误!");

};break;

}

if(F==1)

{F=13;A=A-1;}

if(F==2)

{F=14;A=A-1;}

e=(int)(A/100);

f=(int)(A/400);

g=A-(int)(A/100)*100;

h=(int)(g/4);

i=(int)(3*(F+1)/5);

M=4*e+f+5*g+h+i+E-3;

if(D%2==0)

j=0;

else

j=6;

N=8*e+f+5*g+h+i+j+E+7;

Y=M%10;

W=N%12;

switch(Y)

{case 0:printf("癸");break;

case 1:printf("甲");break;

case 2:printf("乙");break;

case 3:printf("丙");break;

case 4:printf("丁");break;

case 5:printf("戊");break;

case 6:printf("己");break;

case 7:printf("庚");break;

case 8:printf("辛");break;

case 9:printf("壬");break;

case 10:printf("癸");break;

}

switch(W)

{case 0:printf("亥,");break;

case 1:printf("子,");break;

case 2:printf("丑,");break;

case 3:printf("寅,");break;

case 4:printf("卯,");break;

case 5:printf("辰,");break;

case 6:printf("巳,");break;

case 7:printf("午,");break;

case 8:printf("未,");break;

case 9:printf("申,");break;

case 10:printf("酉,");break;

case 11:printf("戌,");break;

case 12:printf("亥,");break;

}

if(Y==1||Y==6)

T=1;

if(Y==2||Y==7)

T=2;

if(Y==3||Y==8)

T=3;

if(Y==4||Y==9)

T=4;

if(Y==5||Y==10||Y==0)

T=5;

if(S==23||S==0||S==24)

t=1;

if(S==1||S==2)

t=2;

if(S==3||S==4)

t=3;

if(S==5||S==6)

t=4;

if(S==7||S==8)

t=5;

if(S==9||S==10)

t=6;

if(S==11||S==12)

t=7;

if(S==13||S==14)

t=8;

if(S==15||S==16)

t=9;

if(S==17||S==18)

t=10;

if(S==19||S==20)

t=11;

if(S==21||S==22)

t=12;

switch(T)

{case 1:

switch(t)

{case 1:printf("甲子");break;

case 2:printf("乙丑");break;

case 3:printf("丙寅");break;

case 4:printf("丁卯");break;

case 5:printf("戊辰");break;

case 6:printf("己巳");break;

case 7:printf("庚午");break;

case 8:printf("辛未");break;

case 9:printf("壬申");break;

case 10:printf("癸酉");break;

case 11:printf("甲戌");break;

case 12:printf("乙亥");break;

};break;

case 2:

switch(t)

{case 1:printf("丙子");break;

case 2:printf("丁丑");break;

case 3:printf("戊寅");break;

case 4:printf("己卯");break;

case 5:printf("庚辰");break;

case 6:printf("辛巳");break;

case 7:printf("壬午");break;

case 8:printf("癸未");break;

case 9:printf("甲申");break;

case 10:printf("乙酉");break;

case 11:printf("丙戌");break;

case 12:printf("丁亥");break;

};break;

case 3:

switch(t)

{case 1:printf("戊子");break;

case 2:printf("己丑");break;

case 3:printf("庚寅");break;

case 4:printf("辛卯");break;

case 5:printf("壬辰");break;

case 6:printf("癸巳");break;

case 7:printf("甲午");break;

case 8:printf("乙未");break;

case 9:printf("丙申");break;

case 10:printf("丁酉");break;

case 11:printf("戊戌");break;

case 12:printf("己亥");break;

};break;

case 4:

switch(t)

{case 1:printf("庚子");break;

case 2:printf("辛丑");break;

case 3:printf("壬寅");break;

case 4:printf("癸卯");break;

case 5:printf("甲辰");break;

case 6:printf("乙巳");break;

case 7:printf("丙午");break;

case 8:printf("丁未");break;

case 9:printf("戊申");break;

case 10:printf("己酉");break;

case 11:printf("庚戌");break;

case 12:printf("辛亥");break;

};break;

case 5:

switch(t)

{case 1:printf("壬子");break;

case 2:printf("癸丑");break;

case 3:printf("甲寅");break;

case 4:printf("乙卯");break;

case 5:printf("丙辰");break;

case 6:printf("丁巳");break;

case 7:printf("戊午");break;

case 8:printf("己未");break;

case 9:printf("庚申");break;

case 10:printf("辛酉");break;

case 11:printf("壬戌");break;

case 12:printf("癸亥");break;

};break;

}

printf("\n您的五行纳音为:");

m=P*10+Q;

switch(m)

{

case 44:printf("海中金");break;

case 55:printf("海中金");break;

case 66:printf("炉中火");break;

case 77:printf("炉中火");break;

case 88:printf("大林木");break;

case 99:printf("大林木");break;

case 10:printf("路旁土");break;

case 21:printf("路旁土");break;

case 20:printf("剑锋金");break;

case 31:printf("剑锋金");break;

case 42:printf("山头火");break;

case 53:printf("山头火");break;

case 64:printf("洞下水");break;

case 75:printf("洞下水");break;

case 86:printf("城墙土");break;

case 97:printf("城墙土");break;

case 8:printf("白腊金");break;

case 19:printf("白腊金");break;

case 30:printf("杨柳木");break;

case 41:printf("杨柳木");break;

case 40:printf("泉中水");break;

case 51:printf("泉中水");break;

case 62:printf("屋上土");break;

case 73:printf("屋上土");break;

case 84:printf("霹雷火");break;

case 95:printf("霹雷火");break;

case 6:printf("松柏木");break;

case 17:printf("松柏木");break;

case 28:printf("常流水");break;

case 39:printf("常流水");break;

case 50:printf("沙中金");break;

case 61:printf("沙中金");break;

case 60:printf("山下火");break;

case 71:printf("山下火");break;

case 82:printf("平地木");break;

case 93:printf("平地木");break;

case 4:printf("壁上土");break;

case 15:printf("壁上土");break;

case 26:printf("金箔金");break;

case 37:printf("金箔金");break;

case 48:printf("佛灯火");break;

case 59:printf("佛灯火");break;

case 70:printf("天河水");break;

case 81:printf("天河水");break;

case 80:printf("大驿土");break;

case 91:printf("大驿土");break;

case 2:printf("钗钏金");break;

case 13:printf("钗钏金");break;

case 24:printf("桑松木");break;

case 35:printf("桑松木");break;

case 46:printf("大溪水");break;

case 57:printf("大溪水");break;

case 68:printf("沙中土");break;

case 79:printf("沙中土");break;

case 90:printf("天上火");break;

case 101:printf("天上火");break;

case 0:printf("石榴木");break;

case 11:printf("石榴木");break;

case 22:printf("大海水");break;

case 33:printf("大海水");break;

}

printf("\n");

system("pause");

}

699ba7046c51816a17b33a7caa85f179.png

0

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值