<kbd id="9plqc"><label id="9plqc"></label></kbd>

        <th id="9plqc"></th>
        1. <center id="9plqc"><video id="9plqc"></video></center>
          <sub id="9plqc"><form id="9plqc"><pre id="9plqc"></pre></form></sub>
          <nav id="9plqc"><form id="9plqc"><legend id="9plqc"></legend></form></nav>
          C語言實(shí)現(xiàn)計(jì)算生辰八字五行的示例代碼,值得收藏 您所在的位置:網(wǎng)站首頁 生辰八字五行算法表 C語言實(shí)現(xiàn)計(jì)算生辰八字五行的示例代碼,值得收藏

          C語言實(shí)現(xiàn)計(jì)算生辰八字五行的示例代碼,值得收藏

          2025-01-04 11:30| 來源: 網(wǎng)絡(luò)整理| 查看: 265

          基于C語言實(shí)現(xiàn)計(jì)算生辰八字五行的示例詳解

          更新時(shí)間:2023年03月28日 16:25:45 作者:老花眼貓

          生辰八字四柱八字五行算法,簡稱八字,是指一個(gè)人出生時(shí)的干支歷日期;年月日時(shí)共四柱干支,每柱兩字,合共八個(gè)字。這篇文章主要介紹了C語言實(shí)現(xiàn)計(jì)算生辰八字五行的示例代碼,需要的可以參考一下

          本文介紹生辰八字和八字五行的一種算法。站內(nèi)有人在查詢生辰八字的算法,此題本人也感興趣。故以此文以續(xù)貂尾。

          生辰八字計(jì)算要點(diǎn)是節(jié)氣日,年柱以立春起,月柱以是月節(jié)氣日起,故先要計(jì)算月首的節(jié)氣日。本節(jié)氣算法的節(jié)氣時(shí)刻精度差些四柱八字五行算法,但確定節(jié)氣日是可以的。程序啟動(dòng)時(shí)先計(jì)算干支表和對(duì)應(yīng)的五行表。具體的計(jì)算方法參閱程序的注釋。算法很簡單,一看就明白。要注意的是,八字的時(shí)柱先輸出的是起時(shí),生日時(shí)辰十二個(gè)時(shí)辰對(duì)應(yīng)下面的起時(shí)表計(jì)算。程序列示文本打印輸出和圖片顯示輸出二種方法供參考。

          本文主要介紹生辰八字的算法,沒有計(jì)算農(nóng)歷日期,農(nóng)歷計(jì)算較為復(fù)雜,加農(nóng)歷算法,加月歷打印輸出成了萬年歷了。

          以下是計(jì)算方法的源碼:

          Canvas cs ; string sBarDes[10]; //按鈕 int nBarId[10]; float src[4]; //ClearDraw (cls) clear screen int ds[3] ; int i,j,t,k; //t = times string fname; //filename 加底圖 int sx, sy, x0, y0 ; int alln,alln1; int ns,leap; double nleap,nleapd; //農(nóng)歷閏月,0無閏,閏月大小 int n,n0,n1,n2 ; string s,s0,ss,s5,s6 ; string s1,s2,s3,s4; string s11, s12, s13, s14 ; int wd ; string wds,wdss; //weekday double dy0,dy1,dm1,dd1; int dy, dm, dd ; string dy2, dm2, dd2 ; //日期輸入dy2 double hh1,mm1,ss1; string hh2,mm2,ss2; int gzy,gzm,gzd,gzh; //干支 yy mm dd hh string gzys,gzms,gzds,gzhs; int gzn1; int yz,mz; //年柱 月柱 string gzs, bzs ; //八字 string whss, g12ss,st28ss; //五行 十二建 二十八宿 string tgs, dzs, whs, whs1, whs2 ; //計(jì)算五行 int dzd0,dzd1; //冬至日 string jqnames ; //節(jié)氣中文名稱 string t1, t2, t3 ; //計(jì)算時(shí)間串 hh;mm;ss double jd; //計(jì)算節(jié)氣 double juD,tht,yrD; double sD; //shouD double vs,dalt; //solar int jqdn ; //節(jié)氣計(jì)算 int jqd1,jqd2 ; string jqs1,jqs2; string jqss1,jqss2; string jnum,jname1, jname2 ; main(){ setDisplay(1); cs.SetBackground(240,240,240); cs.Active(); sBarDes[0]="輸入日期"; nBarId[0]=100; sBarDes[1]=" "; nBarId[1]=101; sBarDes[2]="文本顯示"; nBarId[2]=102; sBarDes[3]="圖片顯示"; nBarId[3]=103; sBarDes[4]="退出程序"; nBarId[4]=104; sBarDes[5]="..."; nBarId[5]=105; setToolBarHeight(6); setButtonTextSize(14); setToolBarBackgroundColor(255,220,220,220); setButtonColor(255,240,240,240); setButtonTextColor(255,0,0,120); setToolBar(100,myToolBarProc,sBarDes,nBarId,6); setTitle("生辰八字五行計(jì)算 "); //********** jqnames="小寒大寒立春雨水驚蟄春分清明谷雨立夏小滿芒種夏至小暑大暑立秋處暑白露秋分寒露霜降立冬小雪大雪冬至"; wdss="星期日星期一星期二星期三星期四星期五星期六" ; whss="海中金爐中火大林木路旁土劍鋒金山頭火洞下水城墻土白臘金楊柳木泉中水屋上土霹雷火松柏木長流水沙中金山下火平地木壁上土金箔金佛燈火天河水大驛土釵釧金桑松木大溪水沙中土天上火石榴木大海水"; g12ss="建除滿平定執(zhí)破危成收開閉"; st28ss="角亢氐房心尾箕斗牛女虛危室壁奎婁胃昴畢觜參井鬼柳星張翼軫"; setDisplay (0); print " 請(qǐng)選擇:輸入日期 " ; bzwh ( ) ; //八字五行計(jì)算 while (){} }//main () bzwh ( ){ //八字干支表gzs五行表 whs int n1,n2 ; tgs="甲乙丙丁戊己庚辛壬癸" ; dzs="子丑寅卯辰巳午未申酉戌亥" ; whs1="木木火火土土金金水水" ; whs2="水土木木土火火土金金土水" ; setDisplay (0); for (i=0; i=jqd1)n=n-1; n1=n-n/12*12; s6=s5+subString(g12ss,n1,1); cs.DrawText (s6, sx+200, sy+380); s="日 : "+s3+s13 ; cs.DrawText (s, sx, sy+380); print "日: "+s3+s13+s6 ; s="時(shí) : "+s4+s14; cs.DrawText (s, sx, sy+410); print "時(shí): "+s4+s14 ; //** 八字起時(shí) ,十二時(shí)辰對(duì)照表 ************* x0=60; y0=600; cs.SetTextSize(24); s="起時(shí) : "; cs.DrawText(s,x0,y0-30); s="23 - 1 11 - 13"; cs.DrawText(s,x0,y0-5); s=" 1 - 3 13 - 15"; cs.DrawText(s,x0,y0+20); s=" 3 - 5 15 - 17"; cs.DrawText(s,x0,y0+45); s=" 5 - 7 17 - 19"; cs.DrawText(s,x0,y0+70); s=" 7 - 9 19 - 21"; cs.DrawText(s,x0,y0+95); s=" 9 - 11 21 - 23"; cs.DrawText(s,x0,y0+120); for(i=0;i2)alln1=alln1+1; // return weekday = wds , alln1 test () ; }//getWeekday () myToolBarProc(int nBtn,int nContext){ if(nBtn==100){//input date setDisplay (0); inputDate ( ) ; } if(nBtn==101){//test input inputDate ( ) ; } if(nBtn==102){//關(guān)閉圖板文本打印輸出 setDisplay (0); } if(nBtn==103){//顯示圖板 setDisplay (1); } if(nBtn==104){//退出程序 clearOutput(); cs.ClearDraw (0,src); setDisplay (0); exit (0); } if(nBtn==105){//@testdraw setDisplay (1); } }//myToolBar () caljq(){//calculate solar ** return jname2 //傳入dy0, n節(jié)氣序數(shù),輸出節(jié)氣時(shí)間 juD=dy0*(365.2423112-0.0000000000000* *(dy0-100)*(dy0-100)- 0.00000003047 *(dy0-100))+15.218427*n+1721050.71301; tht=0.0003*dy0-0.372781384-0.2617913325*n; yrD=(1.945*sin(tht)-0.01206*sin(2*tht)) *(1.048994-0.00002583 *dy0); sD=-0.0018*sin(2.313908653*dy0 -0.439822951-3.0443*n); //'vs = juD '** 平氣 vs = (juD + yrD + sD); // '** 定氣 dalt=-15+(juD-2382148)*(juD-2382148)/41048480; //print dalt; dalt = dalt/8*00; //print dalt; jd = vs - 0.5 - dalt-0.025; int gg; gg=n-(int)(n/2*2); jdtoGD (); jqs1=subString (jqnames,(n-1)*2,2); //print "jqs1 = ",jqs1; s=jqs1+" " +jname2; //print jname2; }//caljq() **************************** //calculate jd to GD ** return jname2 ***** jdtoGD(){ double a,b,c,d,e; double F; double allss; F=jd-(int)(jd); //print " "; //print " JD = ",jd; //print " 時(shí)分秒 日小數(shù) = ",F; a=(int)(jd+0.5); b=a+1537; c=(int)((b-122.1)/365.25); d=(int)(365.25*c); e=(int)((b-d)/30.6001); dd1=b-d-(int)(30.6001*e); dm1=e-1-(int)((e/14)*12); dy1=c-4715-(int)((7+dm1)/10); //print a," ",b," ",c," ",d," ",e; dy2=intToString (dy); dm2=intToString (dm); dd2=doubleToString (dd1); if (len(dm2)==1)dm2="0"+dm2; if (dd1=60){ ss1=ss1-60; mm1=mm1+1;} if(mm1>=60){ mm1=mm1-60; hh1=hh1+1;} //print "JD 轉(zhuǎn)為 GD,計(jì)算結(jié)果:”; hh2=doubleToString(hh1); mm2=doubleToString(mm1); ss2=doubleToString(ss1); if(hh1

          到此這篇關(guān)于基于C語言實(shí)現(xiàn)計(jì)算生辰八字五行的示例詳解的文章就介紹到這了,更多相關(guān)C語言計(jì)算生辰八字五行內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!



          【本文地址】

          公司簡介

          聯(lián)系我們

          今日新聞

          推薦新聞

          專題文章
            CopyRight 2018-2019 實(shí)驗(yàn)室設(shè)備網(wǎng) 版權(quán)所有
            黄色免费网站在线看,韩国精品在线观看,韩国美女一区二区,99国产热 卓资县| 始兴县| 焦作市| 凤阳县| 克东县| 南阳市| 土默特右旗| 大庆市| 含山县| 福建省| 陇南市| 富源县| 阳新县| 汤原县| 山阴县| 临沧市| 郓城县| 开鲁县| 黎平县| 抚远县| 项城市| 南宫市| 凤凰县| 连山| 广丰县| 和田县| 武陟县| 丽水市| 那坡县| 吉木萨尔县| 泌阳县| 汉川市| 会东县| 赤水市| 洱源县| 晋宁县| 崇阳县| 万安县| 上虞市| 大同市| 永靖县| http://444 http://444 http://444 http://444 http://444 http://444