久久国产成人av_抖音国产毛片_a片网站免费观看_A片无码播放手机在线观看,色五月在线观看,亚洲精品m在线观看,女人自慰的免费网址,悠悠在线观看精品视频,一级日本片免费的,亚洲精品久,国产精品成人久久久久久久

分享

計(jì)算生辰八字五行屬性的算法

 虛志山人 2020-05-26

潘愛(ài)民

2013/1/26

 

緣起:幾年前,小兒出生的幾天之內(nèi),,我需要為他起名字,。人生難得接一兩回這樣的任務(wù),更是格外珍惜,。我調(diào)研了幾種起名字的思路,,最終確定按照五行陰陽(yáng)平衡的道理來(lái)確定生辰八字的五行屬性,然后選取恰當(dāng)?shù)淖帧?/p>

 

說(shuō)明:本文描述的算法是根據(jù)Internet上的資料整理而得到,,并非我原創(chuàng),,但個(gè)別地方我做過(guò)修改,。其中經(jīng)驗(yàn)值的出處已無(wú)法找到。

算法的高度足夠,,我是坐在飛機(jī)上寫(xiě)下這一算法描述的,,上萬(wàn)米高空俯瞰大地,感覺(jué)到一種靜默的平衡J,。在過(guò)去幾年中,,我用這一算法測(cè)算過(guò)十多個(gè)生辰八字,也碰到過(guò)一兩個(gè)極端的情形,,與現(xiàn)實(shí)中的表現(xiàn)比較吻合,。因此,我相信這算法的結(jié)果有參考意義,。但是,,因使用該算法引起的任何意外事故,我概不負(fù)責(zé),,請(qǐng)謹(jǐn)慎使用,。

 

算法的過(guò)程如下所述:

1.       根據(jù)出生年月日和時(shí)辰,確定八個(gè)字,,即生辰八字,。

查萬(wàn)年歷(比如www.),確定前六個(gè)字,。比如1968年8月8日,,查到的結(jié)果是:

戊申辛酉壬寅

這六個(gè)字分別是年份的天干、地支,,月份的天干,、地支,和日子的天干,、地支,。

接下來(lái)確定時(shí)辰的天干和地支,查下表:

 

出生
鐘點(diǎn)

時(shí)辰地支

日干(即第5個(gè)字)

甲 己

乙 庚

丙 辛

丁 壬

戊 癸

23-1

1-3

3-5

5-7

7-9

9-11

11-13

13-15

15-17

17-19

19-21

21-23

甲子

乙丑

丙寅

丁卯

戊辰

己巳

庚午

辛未

壬申

癸酉

甲戌

乙亥

丙子

丁丑

戊寅

己卯

庚辰

辛巳

壬午

癸未

甲申

乙酉

丙戌

丁亥

戊子

己丑

庚寅

辛卯

壬辰

癸巳

甲午

乙未

丙申

丁酉

戊戌

己亥

庚子

辛丑

壬寅

癸卯

甲辰

己巳

丙午

丁未

戊申

己酉

庚戌

辛亥

壬子

癸丑

甲寅

乙卯

丙辰

丁巳

戊午

己未

庚申

辛酉

壬戌

癸亥

 

首先根據(jù)出生鐘點(diǎn)找到相應(yīng)的行數(shù),,再根據(jù)第5個(gè)字(日干),,在右邊5列中定位到相應(yīng)的列,即可得到時(shí)辰的天干,、地支,,即第7、8兩個(gè)字,。譬如,,1968年8月8日8點(diǎn)鐘,在“7-9”這一行,“丁壬”這一列,,得到時(shí)辰的干支為“甲辰”,,所以,最終的八字為:

戊申辛酉壬寅甲辰

 

2.       計(jì)算八字的五行屬性,。

首先,,每個(gè)天干和地支都有對(duì)應(yīng)的五行屬性,如下面兩表所示:

 

天干屬性:

天干

屬性

天干

屬性

天干

屬性

 

 

 

 

 

地支屬性:

地支

屬性

地支

屬性

地支

屬性

 

接下來(lái),,計(jì)算五行“金木水火土”的強(qiáng)度值,。對(duì)于五行中的每一行,其強(qiáng)度值包括兩部分:

l  天干強(qiáng)度:即八字中的4個(gè)天干,,若其五行屬性恰好是這一行,,那么就有相應(yīng)的貢獻(xiàn)值,可查表如下:

 

生月\天干

子月

1.2

1.2

1.0

1.0

1.0

1.0

1.0

1.0

1.2

1.2

丑月

1.06

1.06

1.0

1.0

1.1

1.1

1.14

1.14

1.1

1.1

寅月

1.14

1.14

1.2

1.2

1.06

1.06

1.0

1.0

1.0

1.0

卯月

1.2

1.2

1.2

1.2

1.0

1.0

1.0

1.0

1.0

1.0

辰月

1.1

1.1

1.06

1.06

1.1

1.1

1.1

1.1

1.04

1.04

巳月

1.0

1.0

1.14

1.14

1.14

1.14

1.06

1.06

1.06

1.06

午月

1.0

1.0

1.2

1.2

1.2

1.2

1.0

1.0

1.0

1.0

未月

1.04

1.04

1.1

1.1

1.16

1.16

1.1

1.1

1.0

1.0

申月

1.06

1.06

1.0

1.0

1.0

1.0

1.14

1.14

1.2

1.2

酉月

1.0

1.0

1.0

1.0

1.0

1.0

1.2

1.2

1.2

1.2

戌月

1.0

1.0

1.04

1.04

1.14

1.14

1.16

1.16

1.06

1.06

亥月

1.2

1.2

1.0

1.0

1.0

1.0

1.0

1.0

1.14

1.14

 

l  地支強(qiáng)度:即八字中的4個(gè)地支,,它們可能會(huì)藏了這一五行對(duì)應(yīng)的天干,,比如,“丑”藏了“癸,、辛,、己”,而癸,、辛,、己的五行屬性分別是水、金,、土,。所以,地支“丑”對(duì)水,、金,、土都有強(qiáng)度貢獻(xiàn),而強(qiáng)度值的大小則取決于相應(yīng)的月份,。下面的表格涵蓋了地支所藏的五行強(qiáng)度值。

 

 

地支

支藏

月支(即第6個(gè)字)

1.2

1.1

1.0

1.0

1.04

1.06

1.0

1.0

1.2

1.2

1.06

1.14

0.36

0.33

0.3

0.3

0.312

0.318

0.3

0.3

0.36

0.36

0.318

0.342

0.2

0.228

0.2

0.2

0.23

0.212

0.2

0.22

0.228

0.248

0.232

0.2

0.5

0.55

0.53

0.5

0.55

0.57

0.6

0.58

0.5

0.5

0.57

0.5

0.3

0.3

0.36

0.36

0.318

0.342

0.36

0.33

0.3

0.3

0.342

0.318

0.84

0.742

0.798

0.84

0.77

0.7

0.7

0.728

0.742

0.7

0.7

0.84

1.2

1.06

1.14

1.2

1.1

1.0

1.0

1.04

1.06

1.0

1.0

1.2

0.36

0.318

0.342

0.36

0.33

0.3

0.3

0.312

0.318

0.3

0.3

0.36

0.24

0.22

0.2

0.2

0.208

0.2

0.2

0.2

0.24

0.24

0.212

0.228

0.5

0.55

0.53

0.5

0.55

0.6

0.6

0.58

0.5

0.5

0.57

0.5

0.3

0.342

0.3

0.3

0.33

0.3

0.3

0.33

0.342

0.36

0.348

0.3

0.7

0.7

0.84

0.84

0.742

0.84

0.84

0.798

0.7

0.7

0.728

0.742

1.0

1.0

1.2

1.2

1.06

1.14

1.2

1.1

1.0

1.0

1.04

1.06

0.3

0.3

0.36

0.36

0.318

0.342

0.36

0.33

0.3

0.3

0.312

0.318

0.24

0.212

0.228

0.24

0.22

0.2

0.2

0.208

0.212

0.2

0.2

0.24

0.5

0.55

0.53

0.5

0.55

0.57

0.6

0.58

0.5

0.5

0.57

0.5

0.36

0.33

0.3

0.3

0.312

0.318

0.3

0.3

0.36

0.36

0.318

0.342

0.7

0.798

0.7

0.7

0.77

0.742

0.7

0.77

0.798

0.84

0.812

0.7

1.0

1.14

1.0

1.0

1.1

1.06

1.0

1.1

1.14

1.2

1.16

1.0

0.3

0.342

0.3

0.3

0.33

0.318

0.3

0.33

0.342

0.36

0.348

0.3

0.2

0.2

0.24

0.24

0.212

0.228

0.24

0.22

0.2

0.2

0.208

0.212

0.5

0.55

0.53

0.5

0.55

0.57

0.6

0.58

0.5

0.5

0.57

0.5

0.36

0.318

0.342

0.36

0.33

0.3

0.3

0.312

0.318

0.3

0.3

0.36

0.84

0.77

0.7

0.7

0.728

0.742

0.7

0.7

0.84

0.84

0.724

0.798

 

回到前面的例子,,八字“戊申辛酉壬寅甲辰”,,查以上兩表,可以得到五行強(qiáng)度為:

金:0.84 (年支藏庚) + 1.2 (月干) + 1.2 (月支藏辛) = 3.24

木:0.7 (日支藏甲) + 1.0 (時(shí)干) + 0.3 (時(shí)支藏乙) = 2.0

水:0.36 (年支藏壬) + 1.2 (日干) + 0.24 (時(shí)支藏癸) = 1.8

火:0.3 (日支藏丙) = 0.3

土:1.0 (年干) + 0.5 (時(shí)支藏戊) = 1.5

 

3.       給出起名指示,。

首先確定八字的命里屬性,。只需查日干的五行屬性,即代表了該八字的五行屬性,。譬如“戊申辛酉壬寅甲辰”的日干“壬”的屬性為水,,故該八字對(duì)應(yīng)的命里屬性為水。

再計(jì)算同類(lèi)和異類(lèi)的強(qiáng)度值。所謂同類(lèi)是指,,該八字的五行屬性,,以及生該五行屬性的那個(gè)屬性,譬如八字的五行屬性為水,,則水和金合起來(lái)稱為同類(lèi),,其他三個(gè):木、火和土合起來(lái)稱為異類(lèi),。

五行的相生關(guān)系為:金生水,,水生木,木生火,,火生土,,土生金。

得到了同類(lèi)和異類(lèi)的強(qiáng)度值以后,,一個(gè)基本的判斷是,,若兩者的數(shù)值比較接近,則說(shuō)明該八字比較平衡,,也暗示人生平順,;若兩者數(shù)值相差較大(比如,大于1,,甚至大于2),,則說(shuō)明五行不平衡,可以通過(guò)名字來(lái)彌補(bǔ),,或者將來(lái)找對(duì)象時(shí)候通過(guò)婚姻來(lái)補(bǔ)平,。

因此,得到同類(lèi)和異類(lèi)數(shù)值以后,,如何確定“用神”或“喜神”,,或者,如何在名字中補(bǔ)平,,需要一點(diǎn)點(diǎn)人腦智能,,目前尚未量化到算法或程序中?;氐角懊娴睦樱?/p>

日干為壬,,屬水,故命屬水

“同類(lèi)”數(shù)值:5.04

“異類(lèi)”數(shù)值:3.8

“同類(lèi)”比“異類(lèi)”數(shù)值大,,日主強(qiáng),,以火為用神。宜補(bǔ)火,。

最后,,定下怎么補(bǔ)五行屬性以后,剩下就是挑字了,這可以自由發(fā)揮了,??滴踝值渖厦總€(gè)字都有五行屬性,可以在Internet上查到,。

 

 

附上代碼:

文件BaziEval.cpp

 

//BaziEval.cpp : Defines the entry point for the console application.

//

 

#include"stdafx.h"

 

#include<windows.h>

#include<iostream>

usingnamespace std;

 

void Usage()

{

                   cout << "Usage:\tBaziEval.exe -q <生辰八字中之前六字> -t hh" << endl;

                   cout <<"\tBaziEval.exe -e <生辰八字>" << endl;

                   return;

}

 

boolCheckBazi(_TCHAR *bazi);

_TCHAR *ComputeTimeGan(_TCHAR *bazi, int hour);

_TCHAR *EvalBazi(_TCHAR *bazi);

 

 

int_tmain(int argc, _TCHAR* argv[])

{

         _TCHAR *subCmd, *paraStr;

         if (argc != 5 && argc !=3) {

                   Usage();

                   return 0;

         }

        

         subCmd = argv[1];

         paraStr = argv[2];

         if (argc ==5) {

                   // Parsing the part of"-q <生辰八字中之前六字>"

                   if (!(wcslen(subCmd)==1&& subCmd[0] == 'q' || wcslen(subCmd)==2 && subCmd[0]=='-'&& subCmd[1]=='q')) {

                            Usage();

                            return 0;

                   }

 

                   if (wcslen(paraStr)!=6 ||!CheckBazi(paraStr)) {

                            cout <<"-q后面須跟上生辰日的干支,,可以查詢?nèi)f年歷,比如在線版本 http://www./" << endl;

                            Usage();

                            return 0;

                   }

                  

                   // Parsing the part of"-t hh:mm"

                   subCmd = argv[3];

                   paraStr = argv[4];

 

                   if (!(wcslen(subCmd)==1&& subCmd[0] == 't' || wcslen(subCmd)==2 && subCmd[0]=='-'&& subCmd[1]=='t')) {

                            Usage();

                            return 0;

                   }

                  

                   int hour = -1;

                   swscanf(paraStr,L"%d", &hour);

                   if (hour <0 || hour>23) {

                            cout <<"Error: 時(shí)辰參數(shù)不正確,,應(yīng)為0~23之間的一個(gè)整點(diǎn)數(shù),。" << endl;

                            Usage();

                            return 0;

                   }

 

                   _TCHAR * result =ComputeTimeGan(argv[2], hour);

                   if (result == 0) {

                            cout << "查詢不成功!"<< endl;

                   } else {

                            char tmpBuf[128];

                       WideCharToMultiByte( CP_ACP, 0, result, -1,tmpBuf, 127, NULL, NULL );

 

                            cout << "查詢八字的結(jié)果是:"<< tmpBuf << endl;

                            cout << "接下來(lái)您可以用-e命令測(cè)算此八字的五行平衡信息,。" << endl;

                   }

                   return 0;

         }

 

         if (argc ==3) {

                   // Parsingthe part of "-q <生辰八字中之前六字>"

                   if (!(wcslen(subCmd)==1&& subCmd[0] == 'e' || wcslen(subCmd)==2 && subCmd[0]=='-'&& subCmd[1]=='e')) {

                            Usage();

                            return 0;

                   }

 

                   if (wcslen(paraStr)!=8 ||!CheckBazi(paraStr)) {

                            cout <<"-e后面須跟上生辰八字" << endl;

                            Usage();

                            return 0;

                   }

 

                   _TCHAR *result =EvalBazi(paraStr);

                  

                   if (result == 0) {

                            cout << "測(cè)算不成功,,另請(qǐng)高明!"<< endl;

                   } else {

                            char tmpBuf[1024];

                       WideCharToMultiByte( CP_ACP, 0, result, -1,tmpBuf, 1024, NULL, NULL );

 

                            cout <<"\n此八字的五行平衡分析結(jié)果如下:\n\n" << tmpBuf << endl;

                   }

                   return 0;

         }

 

         Usage();

 

         return 0;

}

 

文件BaziAlgorithm.cpp

 

#include "stdafx.h"

 

#include <windows.h>

 

const _TCHAR *TianGan = L"甲乙丙丁戊己庚辛壬癸";

const _TCHAR *DiZhi = L"子丑寅卯辰巳午未申酉戌亥";

 

bool CheckBazi(_TCHAR *bazi)

{

         intbaziLen;

         inti,j;

 

         baziLen= wcslen(bazi);

         if(baziLen != 6 && baziLen != 8 ) return false;

 

         for(i = 0; i < baziLen;) {

                   _TCHARch = bazi[i];

                   for(j = 0; j < 10; j++)

                            if(ch == TianGan[j]) break;

                   if(j >= 10) return false;

                   i++;

 

                   ch= bazi[i];

                   for(j = 0; j < 12; j++)

                            if(ch == DiZhi[j]) break;

                   if(j >= 12) return false;

                   i++;

         }

        

         returntrue;

}

 

/*

根據(jù)出生日子的天干,,通過(guò)下表來(lái)查算時(shí)辰干支:

時(shí)辰干支查算表

時(shí)間時(shí)辰                             五行紀(jì)日干支

                       甲己     乙庚     丙辛     丁壬     戊癸

 

23-01 子/水           甲子     丙子     戊子     庚子     壬子

01-03 丑/土           乙丑     丁丑     己丑     辛丑     癸丑

03-05 寅/木           丙寅     戊寅     庚寅     壬寅     甲寅

05-07 卯/木           丁卯     己卯     辛卯     癸卯     乙卯

07-09 辰/土           戊辰     庚辰     壬辰     甲辰     丙辰

09-11 巳/火           己巳     辛巳     癸巳     己巳     丁巳

11-13 午/火           庚午     壬午     甲午     丙午     戊午

13-15 未/土           辛未     癸未     乙未     丁未     己未

15-17 申/金           壬申     甲申     丙申     戊申     庚申

17-19 酉/金           癸酉     乙酉     丁酉     己酉     辛酉

19-21 戊/土           甲戌     丙戌     戊戌     庚戌     壬戌

21-23 亥/水           乙亥     丁亥     己亥     辛亥     癸亥

 

*/

const _TCHAR * cTimeGanZhi_Table[12][5] =

{

         {L"甲子",L"丙子", L"戊子", L"庚子", L"壬子"},

         {L"乙丑",L"丁丑", L"己丑", L"辛丑", L"癸丑"},

         {L"丙寅",L"戊寅", L"庚寅", L"壬寅", L"甲寅"},

         {L"丁卯",L"己卯", L"辛卯", L"癸卯", L"乙卯"},

         {L"戊辰",L"庚辰", L"壬辰", L"甲辰", L"丙辰"},

         {L"己巳",L"辛巳", L"癸巳", L"己巳", L"丁巳"},

         {L"庚午", L"壬午",L"甲午", L"丙午", L"戊午"},

         {L"辛未",L"癸未", L"乙未", L"丁未", L"己未"},

         {L"壬申",L"甲申", L"丙申", L"戊申", L"庚申"},

         {L"癸酉",L"乙酉", L"丁酉", L"己酉", L"辛酉"},

         {L"甲戌",L"丙戌", L"戊戌", L"庚戌", L"壬戌"},

         {L"乙亥",L"丁亥", L"己亥", L"辛亥", L"癸亥"}

};

 

static _TCHAR sBuf[128];        // 用作八字結(jié)果緩沖區(qū)

 

// 根據(jù)出生年月日的干支計(jì)算時(shí)辰干支

// 輸入?yún)?shù):bazi,,年月日的干支,即八字中的前六個(gè)字

// 輸入?yún)?shù):hour,,出生時(shí)間的小時(shí)數(shù),,-1~22

// 輸出結(jié)果:八字字符串,Unicode編碼

_TCHAR * ComputeTimeGan(_TCHAR *bazi, inthour)

{

         _TCHARdayGan = bazi[4];

 

         intindexX, indexY;

        

         inti;

         for(i = 0; i < 10; i++)

                   if(dayGan == TianGan[i]) break;

         if(i >= 10) return 0;

         indexX= i;

         if(indexX >=5) indexX -= 5;

         indexY= (hour +1)/2;

 

         wcscpy(sBuf,bazi);

         wcscat(sBuf,cTimeGanZhi_Table[indexY][indexX]);

 

         returnsBuf;

}

 

/*

十二月份天干強(qiáng)度表

生月\四柱天干        甲              乙              丙              丁              戊              己              庚              辛              壬              癸

子月                            1.2             1.2             1.0             1.0             1.0             1.0             1.0             1.0             1.2             1.2

丑月                            1.06 1.06 1.0             1.0             1.1             1.1             1.14 1.14 1.1             1.1

寅月                            1.14 1.14 1.2             1.2             1.06 1.06 1.0             1.0             1.0             1.0

卯月                            1.2             1.2             1.2             1.2             1.0             1.0             1.0             1.0             1.0             1.0

辰月                            1.1             1.1             1.06 1.06 1.1             1.1             1.1             1.1             1.04 1.04

巳月                            1.0             1.0             1.14 1.14 1.14 1.14 1.06 1.06 1.06 1.06

午月                            1.0             1.0             1.2             1.2             1.2             1.2             1.0             1.0             1.0             1.0

未月                            1.04 1.04 1.1             1.1             1.16 1.16 1.1             1.1             1.0             1.0

申月                            1.06 1.06 1.0             1.0             1.0             1.0             1.14 1.14 1.2             1.2

酉月                            1.0             1.0             1.0             1.0             1.0             1.0             1.2             1.2             1.2             1.2

戌月                            1.0             1.0             1.04 1.04 1.14 1.14 1.16 1.16 1.06 1.06

亥月                            1.2             1.2             1.0             1.0             1.0             1.0             1.0             1.0             1.14 1.14

*/

 

double TianGan_Strength [12][10] =

{

         {1.2, 1.2,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.2,  1.2},

         {1.06,        1.06,         1.0,  1.0,  1.1,  1.1,  1.14,         1.14,         1.1,  1.1},

         {1.14,        1.14,         1.2,  1.2,  1.06,         1.06,         1.0,  1.0,  1.0,  1.0},

         {1.2, 1.2,  1.2,  1.2,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0},

         {1.1, 1.1,  1.06,         1.06,         1.1,  1.1,  1.1,  1.1,  1.04,         1.04},

         {1.0, 1.0,  1.14,         1.14,         1.14,         1.14,         1.06,         1.06,         1.06,         1.06},

         {1.0, 1.0,  1.2,  1.2,  1.2,  1.2,  1.0,  1.0,  1.0,  1.0},

         {1.04,        1.04,         1.1,  1.1,  1.16,         1.16,         1.1,  1.1,  1.0,  1.0},

         {1.06,        1.06,         1.0,  1.0,  1.0,  1.0,  1.14,         1.14,         1.2,  1.2},

         {1.0, 1.0,  1.0,  1.0,  1.0,  1.0,  1.2,  1.2,  1.2,  1.2},

         {1.0, 1.0,  1.04,         1.04,         1.14,         1.14,         1.16,         1.16,         1.06,         1.06},

         {1.2, 1.2,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.14,         1.14}

};

 

/*

十二月份地支強(qiáng)度表

 

                        生月       子月         丑月         寅月         卯月         辰月         巳月         午月         未月         申月         酉月         戌月         亥月        

地支         支藏

子              癸                       1.2             1.1             1.0             1.0             1.04 1.06 1.0             1.0             1.2             1.2             1.06 1.14

丑              癸                       0.36 0.33 0.3             0.3             0.312        0.318        0.3             0.3             0.36 0.36 0.318        0.342

丑              辛                       0.2             0.228        0.2             0.2             0.23 0.212        0.2             0.22 0.228        0.248        0.232        0.2           

丑              己                       0.5             0.55 0.53 0.5             0.55 0.57 0.6             0.58 0.5             0.5             0.57 0.5            

寅              丙                       0.3             0.3             0.36 0.36 0.318        0.342        0.36 0.33 0.3             0.3             0.342        0.318       

寅              甲                       0.84 0.742        0.798        0.84 0.77 0.7             0.7             0.728        0.742        0.7             0.7             0.84

卯              乙                       1.2             1.06 1.14 1.2             1.1             1.0             1.0             1.04 1.06 1.0             1.0             1.2            

辰              乙                       0.36 0.318        0.342        0.36 0.33 0.3             0.3             0.312        0.318        0.3             0.3             0.36

辰              癸                       0.24 0.22 0.2             0.2             0.208        0.2             0.2             0.2             0.24 0.24 0.212        0.228       

辰              戊                       0.5             0.55 0.53 0.5             0.55 0.6             0.6             0.58 0.5             0.5             0.57 0.5            

巳              庚                       0.3             0.342        0.3             0.3             0.33 0.3             0.3             0.33 0.342        0.36 0.348        0.3            

巳              丙                       0.7             0.7             0.84 0.84 0.742        0.84 0.84 0.798        0.7             0.7             0.728        0.742       

午              丁                       1.0             1.0             1.2             1.2             1.06 1.14 1.2             1.1             1.0             1.0             1.04 1.06

未              丁                       0.3             0.3             0.36 0.36 0.318        0.342        0.36 0.33 0.3             0.3             0.312        0.318       

未              乙                       0.24 0.212        0.228        0.24 0.22 0.2             0.2             0.208        0.212        0.2             0.2             0.24

未              己                       0.5             0.55 0.53 0.5             0.55 0.57 0.6             0.58 0.5             0.5             0.57 0.5            

申              壬                       0.36 0.33 0.3             0.3             0.312        0.318        0.3             0.3             0.36 0.36 0.318        0.342       

申              庚                       0.7             0.798        0.7             0.7             0.77 0.742        0.7             0.77 0.798        0.84 0.812        0.7            

酉              辛                       1.0             1.14 1.0             1.0             1.1             1.06 1.0             1.1             1.14 1.2             1.16 1.0            

戌              辛                       0.3             0.342        0.3             0.3             0.33 0.318        0.3             0.33 0.342        0.36 0.348        0.3            

戌              丁                       0.2             0.2             0.24 0.24 0.212        0.228        0.24 0.22 0.2             0.2             0.208        0.212       

戌              戊                       0.5             0.55 0.53 0.5             0.55 0.57 0.6             0.58 0.5             0.5             0.57 0.5            

亥              甲                       0.36 0.318        0.342        0.36 0.33 0.3             0.3             0.312        0.318        0.3             0.3             0.36

亥              壬                        0.84 0.77 0.7             0.7             0.728        0.742        0.7             0.7             0.84 0.84 0.724        0.798       

*/

struct ZISTRENGTH {

         _TCHARdiZhi;

         _TCHARzhiCang;

         doublestrength[12];

};

 

ZISTRENGTHDiZhi_Strength [] =

{

         {L'子', L'癸', {1.2,1.1, 1.0, 1.0,        1.04, 1.06, 1.0,1.0, 1.2, 1.2, 1.06, 1.14}},     

         {L'丑', L'癸', {0.36,0.33, 0.3, 0.3, 0.312, 0.318, 0.3, 0.3, 0.36, 0.36, 0.318, 0.342}},

         {L'丑', L'辛', {0.2,0.228, 0.2, 0.2, 0.23, 0.212, 0.2,         0.22,0.228, 0.248, 0.232, 0.2}},              

         {L'丑', L'己', {0.5,0.55, 0.53, 0.5, 0.55, 0.57, 0.6, 0.58, 0.5, 0.5, 0.57, 0.5}},                 

         {L'寅', L'丙', {0.3,0.3, 0.36, 0.36, 0.318, 0.342, 0.36, 0.33, 0.3, 0.3, 0.342, 0.318}},   

         {L'寅', L'甲', {0.84,0.742, 0.798, 0.84, 0.77, 0.7, 0.7, 0.728, 0.742, 0.7, 0.7, 0.84}},   

         {L'卯', L'乙', {1.2,1.06, 1.14, 1.2, 1.1, 1.0, 1.0, 1.04, 1.06, 1.0, 1.0, 1.2}},             

         {L'辰', L'乙', {0.36,0.318, 0.342, 0.36, 0.33, 0.3, 0.3, 0.312, 0.318, 0.3, 0.3, 0.36}},   

         {L'辰', L'癸', {0.24,0.22,  0.2, 0.2, 0.208, 0.2, 0.2, 0.2,0.24, 0.24, 0.212, 0.228}},       

         {L'辰', L'戊', {0.5,0.55, 0.53, 0.5, 0.55, 0.6, 0.6, 0.58, 0.5, 0.5, 0.57, 0.5}},          

         {L'巳', L'庚', {0.3,0.342, 0.3, 0.3, 0.33, 0.3, 0.3, 0.33, 0.342, 0.36, 0.348, 0.3}},          

         {L'巳', L'丙', {0.7,0.7, 0.84, 0.84, 0.742, 0.84, 0.84, 0.798, 0.7, 0.7, 0.728, 0.742}},   

         {L'午', L'丁', {1.0,1.0, 1.2, 1.2, 1.06, 1.14, 1.2, 1.1, 1.0, 1.0, 1.04, 1.06}},   

         {L'未', L'丁', {0.3,0.3, 0.36, 0.36, 0.318, 0.342, 0.36, 0.33, 0.3, 0.3, 0.312, 0.318}},   

         {L'未', L'乙', {0.24,0.212, 0.228, 0.24, 0.22, 0.2, 0.2, 0.208, 0.212, 0.2, 0.2, 0.24}},   

         {L'未', L'己', {0.5,0.55, 0.53, 0.5, 0.55, 0.57, 0.6, 0.58, 0.5, 0.5, 0.57, 0.5}},                 

         {L'申', L'壬', {0.36,0.33, 0.3, 0.3, 0.312, 0.318, 0.3, 0.3, 0.36, 0.36, 0.318, 0.342}},   

         {L'申', L'庚', {0.7,0.798, 0.7, 0.7, 0.77, 0.742, 0.7, 0.77, 0.798, 0.84, 0.812, 0.7}},               

         {L'酉', L'辛', {1.0,1.14, 1.0, 1.0, 1.1, 1.06, 1.0, 1.1, 1.14, 1.2, 1.16, 1.0}},             

         {L'戌', L'辛', {0.3,0.342, 0.3, 0.3, 0.33, 0.318, 0.3, 0.33, 0.342, 0.36, 0.348, 0.3}},               

         {L'戌', L'丁', {0.2,0.2, 0.24, 0.24, 0.212, 0.228, 0.24, 0.22, 0.2, 0.2, 0.208, 0.212}},   

         {L'戌', L'戊', {0.5,0.55, 0.53, 0.5, 0.55, 0.57, 0.6, 0.58, 0.5, 0.5, 0.57, 0.5}},                 

         {L'亥', L'甲', {0.36,0.318, 0.342, 0.36, 0.33, 0.3, 0.3, 0.312, 0.318, 0.3, 0.3, 0.36}},   

         {L'亥', L'壬', {0.84,0.77, 0.7, 0.7, 0.728, 0.742, 0.7, 0.7, 0.84, 0.84, 0.724, 0.798}}     

};

 

/*

         金 --- 0

         木 --- 1

         水 --- 2

         火 --- 3

         土 --- 4

*/

 

_TCHAR WuXingTable[5] = {L'金', L'木', L'水', L'火', L'土' };

 

/*

         天干地支的五行屬性表

         天干: 甲-木、乙-木、丙-火,、丁-火,、戊-土、己-土,、庚-金,、辛-金、壬-水,、癸-水

         地支:子-水,、丑-土、寅-木,、卯-木,、辰-土、巳-火,、午-火,、未-土,、申-金,、酉-金、戌-土、亥-水

*/

 

int TianGan_WuXingProp[10] = {1, 1, 3, 3, 4,4, 0, 0, 2, 2};

int DiZhi_WuXingProp[12] = {2, 4, 1, 1, 4,3, 3, 4, 0, 0, 4, 2};

int GenerationSourceTable[5] = {4, 2, 0, 1,3};

 

int ComputeGanIndex(_TCHAR gan)

{

         inti;

         for(i=0; i < 10; i++)

                   if(TianGan[i] == gan) break;

         if(i >= 10) return -1;

         returni;

}

 

int ComputeZhiIndex(_TCHAR zhi)

{

         inti;

         for(i=0; i < 12; i++)

                   if(DiZhi[i] == zhi) break;

         if(i >= 12) return -1;

         returni;

}

 

static _TCHAR sResultBuf[1024];   // 用作八字測(cè)算結(jié)果返回的字符緩沖區(qū)

 

// 根據(jù)八字計(jì)算五行平衡

// 輸入?yún)?shù):bazi,,年月日時(shí)的干支,,即俗稱的八字

// 輸出結(jié)果:分析結(jié)果字符串,Unicode編碼

_TCHAR * EvalBazi(_TCHAR *bazi)

{

         doublestrengthResult[5];

         intmonthIndex = ComputeZhiIndex(bazi[3]);

         if(monthIndex == -1) goto ERROR_CASE;

 

         wcscpy(sResultBuf,bazi);

         wcscat(sResultBuf,L"\n\n");

         for(int wuXing = 0; wuXing < 5; wuXing++) {

                   doublevalue1 = 0.0, value2 = 0.0;

                   inti;

                   //掃描4個(gè)天干

                   for(i  = 0; i <8; i+=2) {

                            TCHARgan = bazi[i];

                            intindex = ComputeGanIndex(gan);

                            if(index == -1) goto ERROR_CASE;

 

                            if(TianGan_WuXingProp[index] == wuXing)

                                     value1+= TianGan_Strength[monthIndex][index];

                   }

 

                   //掃描支藏

                   for(i  = 1; i <8; i+=2) {

                            TCHARzhi = bazi[i];

                            for(intj = 0; j < sizeof (DiZhi_Strength)/sizeof (DiZhi_Strength[0]); j++) {

                                     if(DiZhi_Strength[j].diZhi == zhi) {

                                               intzhiCangIndex = ComputeGanIndex(DiZhi_Strength[j].zhiCang);

                                               if(zhiCangIndex == -1) goto ERROR_CASE;

                                               if(TianGan_WuXingProp[zhiCangIndex] == wuXing) {

                                                        value2+= DiZhi_Strength[j].strength[monthIndex];

                                                        break;

                                               }

                                     }

                            }

                   }

 

                   strengthResult[wuXing]= value1 + value2;

 

                   //輸出一行計(jì)算結(jié)果

                   {

                            _TCHARpreStr[128];

                            chartmpBuf[128];

                            _TCHARtmpWBuf[256];

                            sprintf(tmpBuf,":%.3f + %.3f = %.3f\n", (float)value1, (float)value2,(float)(value1+value2));

                            MultiByteToWideChar(CP_ACP, 0, tmpBuf, strlen(tmpBuf)+1,

                                     tmpWBuf,sizeof(tmpWBuf)/sizeof(_TCHAR) );

                            wcscpy(preStr,L"金:\t");

                            preStr[0]= WuXingTable[wuXing];

                            wcscat(sResultBuf,preStr);

                            wcscat(sResultBuf,tmpWBuf);

                   }

         }

        

         //根據(jù)日干求命里屬性

         intfateProp, srcProp;

 

         {

                   _TCHARtmpWBuf[256];

                   fateProp= TianGan_WuXingProp[ComputeGanIndex(bazi[4])];

                   if(fateProp == -1) goto ERROR_CASE;

                   wcscpy(tmpWBuf,L"\n命屬金\n\n");

                   tmpWBuf[3]= WuXingTable[fateProp];

                   wcscat(sResultBuf,tmpWBuf);

 

         }

 

         //求同類(lèi)和異類(lèi)的強(qiáng)度值

         srcProp= GenerationSourceTable[fateProp];

         {

                   _TCHARpreStr[128];

                   chartmpBuf[128];

                   _TCHARtmpWBuf[256];

 

                   doubletongLei = strengthResult[fateProp] + strengthResult[srcProp];

                   doubleyiLei = 0.0;

                   for(inti = 0; i < 5; i ++) yiLei += strengthResult[i];

                   yiLei-= tongLei;

                  

                   sprintf(tmpBuf,"%.3f+ %.3f = %.3f\n", (float)strengthResult[fateProp],(float)strengthResult[srcProp],

                            (float)tongLei);

                   MultiByteToWideChar(CP_ACP, 0, tmpBuf, strlen(tmpBuf)+1,

                            tmpWBuf,sizeof(tmpWBuf)/sizeof(_TCHAR) );

                   wcscpy(preStr,L"同類(lèi):金+金,,");

                   preStr[3]= WuXingTable[fateProp];

                   preStr[5]= WuXingTable[srcProp];

                   wcscat(sResultBuf,preStr);

                   wcscat(sResultBuf,tmpWBuf);

 

                   sprintf(tmpBuf,"%.3f\n", (float)yiLei);

                   MultiByteToWideChar(CP_ACP, 0, tmpBuf, strlen(tmpBuf)+1,

                            tmpWBuf,sizeof(tmpWBuf)/sizeof(_TCHAR) );

                   wcscat(sResultBuf,L"異類(lèi):總和為 ");

                   wcscat(sResultBuf,tmpWBuf);

         }

 

         returnsResultBuf;

 

ERROR_CASE:

        

         return0;

}

 

    本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,,不代表本站觀點(diǎn),。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買(mǎi)等信息,,謹(jǐn)防詐騙,。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào),。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評(píng)論

    發(fā)表

    請(qǐng)遵守用戶 評(píng)論公約

    類(lèi)似文章 更多