C prepared by the birth of eight character calculation procedures

  • 2021-01-18 06:36:31
  • OfStack

The author deliberately deleted the comment, do not understand the code, add the author QQ721159175 consultation, the author is very happy to share with you and answer ~


using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            // Assuming that 1 The individual's date of birth in the Gregorian calendar must be in the range 2012-2015 Years, because this sample program only provides the lunar calendar data for those years
            // Modify these assignments, run the program, you can get the birth date 8 word
            GuaZhu.nQiGuaYear = 2015;// years
            GuaZhu.nQiGuaMonth = 2;// month
            GuaZhu.nQiGuaDay = 6;// day
            GuaZhu.nQiGuaHour = 23;// when
            GuaZhu.nQiGuaMinute = 33;// points
            GuaZhu.GetSiZhu();
        }
    }
    public static class GuaZhu
    {
        public static int nQiGuaYear;
        public static int nQiGuaMonth;
        public static int nQiGuaDay;
        public static int nQiGuaHour;
        public static int nQiGuaMinute;
        public static int JieQiMonth;
        public static string PrevJQYear;
        public static string PrevJQMonth;
        public static string PrevJQDay;
        public static string PrevJQHour;
        public static string PrevJQMinute;
        public static string NextJQYear;
        public static string NextJQMonth;
        public static string NextJQDay;
        public static string NextJQHour;
        public static string NextJQMinute;
        public static string sSiZhu;
        public static string nTianGan;
        public static string yTianGan;
        public static string rTianGan;
        public static string sTianGan;
        public static string nDiZhi;
        public static string yDiZhi;
        public static string rDiZhi;
        public static string sDiZhi;
        public static int nTianGanID;
        public static int yTianGanID;
        public static int rTianGanID;
        public static string PrevJieQi;
        public static string NextJieQi;
        public static string[] TianGan = { " a ", " b ", " c ", " ding ", " e ", " f ", " heptyl ", " simba ", " nonyl ", " decyl " };
        public static string[] DiZhi = { " The child ", " The ugly ", " Yin ", " sockets ", " Chen" ", " The third ", " noon ", " not ", " " ", " unitary ", " xu-gou ", " hai " };
        public static string[] JieQi = {
"1/6/2012 06:44","2/4/2012 18:22","3/5/2012 12:21","4/4/2012 17:06","5/5/2012 10:20","6/5/2012 14:26","7/7/2012 00:41",
"8/7/2012 10:31","9/7/2012 13:29","10/8/2012 05:12","11/7/2012 08:26","12/7/2012 01:19","1/5/2013 12:34","2/4/2013 00:13",
"3/5/2013 18:15","4/4/2013 23:02","5/5/2013 16:18","6/5/2013 20:23","7/7/2013 06:35","8/7/2013 16:20","9/7/2013 19:16",
"10/8/2013 10:58","11/7/2013 14:14","12/7/2013 07:09","1/5/2014 18:24","2/4/2014 06:03","3/6/2014 00:02","4/5/2014 04:47",
"5/5/2014 21:59","6/6/2014 02:03","7/7/2014 12:15","8/7/2014 22:03","9/8/2014 01:01","10/8/2014 16:48","11/7/2014 20:07",
"12/7/2014 13:04","1/6/2015 00:20","2/4/2015 11:58","3/6/2015 05:55","4/5/2015 10:39","5/6/2015 03:52","6/6/2015 07:58",
"7/7/2015 18:12","8/6/2015 04:01","9/8/2015 06:59","10/8/2015 22:43","11/8/2015 01:58","12/7/2015 18:53",
};
        public static void GetnGanZhi()
        {
            int year, year1, year2;
            year = GuaZhu.nQiGuaYear;
            if (GuaZhu.nQiGuaMonth == 1)
            {
                year -= 1;
            }
            else if (GuaZhu.nQiGuaMonth == 2)
            {
                DateTime lichun, birthday1;
                lichun = DateTime.Parse("2012-2-4 18:22");
                string birthday2;
                switch (GuaZhu.nQiGuaYear - 2012)
                {
                    case 0:
                        lichun = DateTime.Parse("2012-2-4 18:22");
                        break;
                    case 1:
                        lichun = DateTime.Parse("2013-2-4 00:13");
                        break;
                    case 2:
                        lichun = DateTime.Parse("2014-2-4 06:03");
                        break;
                    case 3:
                        lichun = DateTime.Parse("2015-2-4 11:58");
                        break;
                }
                birthday2 = GuaZhu.nQiGuaYear + "-" + GuaZhu.nQiGuaMonth + "-" + GuaZhu.nQiGuaDay + " " + GuaZhu.nQiGuaHour + ":" + GuaZhu.nQiGuaMinute;
                birthday1 = DateTime.Parse(birthday2);
                if (birthday1 < lichun)
                {
                    year -= 1;
                }
            }
            year1 = year % 10 < 4 ? (year % 10 + 10) : year % 10;
            year2 = year % 12 < 4 ? (year % 12 + 12) : year % 12;
            nTianGan = TianGan[year1 - 4];
            nDiZhi = DiZhi[year2 - 4];
        }
        public static void GetYueGan()
        {
            yTianGanID = nTianGanID * 2 + JieQiMonth + 1;
            if ((yTianGanID >= 10) && (yTianGanID < 20))
            {
                yTianGanID -= 10;
            }
            else if (yTianGanID >= 20)
            {
                yTianGanID -= 20;
            }
            if (yTianGanID == 10)
            {
                yTianGanID = 0;
            }
            yTianGan = TianGan[yTianGanID];
        }
        public static void GetyGanZhi()
        {
            string sJieQiName1 = "", sJieQiName2 = "";
            string birthday2;
            birthday2 = GuaZhu.nQiGuaYear + "-" + GuaZhu.nQiGuaMonth + "-" + GuaZhu.nQiGuaDay + " " + GuaZhu.nQiGuaHour + ":" + GuaZhu.nQiGuaMinute;
            DateTime date = DateTime.Parse(birthday2);
            for (int i = 46; i > -1; i--)
            {
                if ((i + 1) % 12 > 8)
                {
                    PrevJQYear = JieQi[i + 1].Substring(5, 4);
                    PrevJQMonth = JieQi[i + 1].Substring(0, 2);
                    PrevJQDay = JieQi[i + 1].Substring(3, 1);
                }
                else
                {
                    PrevJQYear = JieQi[i + 1].Substring(4, 4);
                    PrevJQMonth = JieQi[i + 1].Substring(0, 1);
                    PrevJQDay = JieQi[i + 1].Substring(2, 1);
                }
                PrevJQHour = JieQi[i + 1].Substring(JieQi[i + 1].Length - 5, 2);
                PrevJQMinute = JieQi[i + 1].Substring(JieQi[i + 1].Length - 2, 2);
                PrevJieQi = PrevJQYear + "-" + PrevJQMonth + "-" + PrevJQDay + " " + PrevJQHour + ":" + PrevJQMinute;
                if (i % 12 > 8)
                {
                    NextJQYear = JieQi[i].Substring(5, 4);
                    NextJQMonth = JieQi[i].Substring(0, 2);
                    NextJQDay = JieQi[i].Substring(3, 1);
                }
                else
                {
                    NextJQYear = JieQi[i].Substring(4, 4);
                    NextJQMonth = JieQi[i].Substring(0, 1);
                    NextJQDay = JieQi[i].Substring(2, 1);
                }
                NextJQHour = JieQi[i].Substring(JieQi[i].Length - 5, 2);
                NextJQMinute = JieQi[i].Substring(JieQi[i].Length - 2, 2);
                NextJieQi = NextJQYear + "-" + NextJQMonth + "-" + NextJQDay + " " + NextJQHour + ":" + NextJQMinute;
                DateTime date2 = DateTime.Parse(NextJieQi);
                if (date >= date2)
                {
                    switch (i % 12)
                    {
                        case 1:
                            sJieQiName1 = " Spring: ";
                            sJieQiName2 = " Insects: ";
                            JieQiMonth = 1;
                            break;
                        case 2:
                            sJieQiName1 = " Insects: ";
                            sJieQiName2 = " The tomb-sweeping day: ";
                            JieQiMonth = 2;
                            break;
                        case 3:
                            sJieQiName1 = " The tomb-sweeping day: ";
                            sJieQiName2 = " Summer begins: ";
                            JieQiMonth = 3;
                            break;
                        case 4:
                            sJieQiName1 = " Summer begins: ";
                            sJieQiName2 = " Grain in ear: ";
                            JieQiMonth = 4;
                            break;
                        case 5:
                            sJieQiName1 = " Grain in ear: ";
                            sJieQiName2 = " Slight heat: ";
                            JieQiMonth = 5;
                            break;
                        case 6:
                            sJieQiName1 = " Slight heat: ";
                            sJieQiName2 = " Autumn: ";
                            JieQiMonth = 6;
                            break;
                        case 7:
                            sJieQiName1 = " Autumn: ";
                            sJieQiName2 = " White dew: ";
                            JieQiMonth = 7;
                            break;
                        case 8:
                            sJieQiName1 = " White dew: ";
                            sJieQiName2 = " Cold dew: ";
                            JieQiMonth = 8;
                            break;
                        case 9:
                            sJieQiName1 = " Cold dew: ";
                            sJieQiName2 = " The beginning of winter. ";
                            JieQiMonth = 9;
                            break;
                        case 10:
                            sJieQiName1 = " The beginning of winter. ";
                            sJieQiName2 = " Snow: ";
                            JieQiMonth = 10;
                            break;
                        case 11:
                            sJieQiName1 = " Snow: ";
                            sJieQiName2 = " Slight cold: ";
                            JieQiMonth = 11;
                            break;
                        case 0:
                            sJieQiName1 = " Slight cold: ";
                            sJieQiName2 = " Spring: ";
                            JieQiMonth = 12;
                            break;
                    }
                    PrevJieQi = sJieQiName2 + PrevJQYear + " years " + PrevJQMonth + " month " + PrevJQDay + " day " + PrevJQHour + " when " + PrevJQMinute + " points ";
                    NextJieQi = sJieQiName1 + NextJQYear + " years " + NextJQMonth + " month " + NextJQDay + " day " + NextJQHour + " when " + NextJQMinute + " points ";
                    break;
                }
            }
            switch (nTianGan)
            {
                case " a ":
                    nTianGanID = 0;
                    GetYueGan();
                    break;
                case " b ":
                    nTianGanID = 1;
                    GetYueGan();
                    break;
                case " c ":
                    nTianGanID = 2;
                    GetYueGan();
                    break;
                case " ding ":
                    nTianGanID = 3;
                    GetYueGan();
                    break;
                case " e ":
                    nTianGanID = 4;
                    GetYueGan();
                    break;
                case " f ":
                    nTianGanID = 5;
                    GetYueGan();
                    break;
                case " heptyl ":
                    nTianGanID = 6;
                    GetYueGan();
                    break;
                case " simba ":
                    nTianGanID = 7;
                    GetYueGan();
                    break;
                case " nonyl ":
                    nTianGanID = 8;
                    GetYueGan();
                    break;
                case " decyl ":
                    nTianGanID = 9;
                    GetYueGan();
                    break;
            }
            if (JieQiMonth <= 10)
            {
                yDiZhi = DiZhi[JieQiMonth + 1];
            }
            else if (JieQiMonth == 11)
            {
                JieQiMonth = 0;
                yDiZhi = DiZhi[JieQiMonth];
            }
            else
            {
                JieQiMonth = 1;
                yDiZhi = DiZhi[JieQiMonth];
            }
        }
        public static void GetrGanZhi()
        {
            DateTime baseDate = new DateTime(2000, 1, 1);
            DateTime qiguaDate = new DateTime(GuaZhu.nQiGuaYear, GuaZhu.nQiGuaMonth, GuaZhu.nQiGuaDay);
            TimeSpan ts = qiguaDate - baseDate;
            int gapdays = ts.Days;
            if (GuaZhu.nQiGuaHour == 23)
            {
                gapdays += 1;
            }
            if (gapdays >= 6)
            {
                rTianGan = TianGan[(gapdays - 6) % 10];
                rDiZhi = DiZhi[(gapdays - 6) % 12];
            }
            else if (gapdays < 0)
            {
                gapdays = gapdays * (-1);
                rTianGan = TianGan[(gapdays + 6) % 10];
                rDiZhi = DiZhi[(gapdays + 6) % 12];
            }
            else
            {
                switch (gapdays)
                {
                    case 0:
                        rTianGan = " e ";
                        rDiZhi = " noon ";
                        break;
                    case 1:
                        rTianGan = " f ";
                        rDiZhi = " not ";
                        break;
                    case 2:
                        rTianGan = " heptyl ";
                        rDiZhi = " " ";
                        break;
                    case 3:
                        rTianGan = " simba ";
                        rDiZhi = " unitary ";
                        break;
                    case 4:
                        rTianGan = " nonyl ";
                        rDiZhi = " xu-gou ";
                        break;
                    case 5:
                        rTianGan = " decyl ";
                        rDiZhi = " hai ";
                        break;
                }
            }
        }
        public static void GetShiGan()
        {
            if (GuaZhu.nQiGuaHour == 23 || GuaZhu.nQiGuaHour == 0)
            {
                rTianGanID = 0 + rTianGanID;
                rTianGanID = rTianGanID > 9 ? (rTianGanID - 10) : rTianGanID;
                sTianGan = TianGan[rTianGanID];
            }
            else if (GuaZhu.nQiGuaHour == 1 || GuaZhu.nQiGuaHour == 2)
            {
                rTianGanID = 1 + rTianGanID;
                rTianGanID = rTianGanID > 9 ? (rTianGanID - 10) : rTianGanID;
                sTianGan = TianGan[rTianGanID];
            }
            else if (GuaZhu.nQiGuaHour == 3 || GuaZhu.nQiGuaHour == 4)
            {
                rTianGanID = 2 + rTianGanID;
                rTianGanID = rTianGanID > 9 ? (rTianGanID - 10) : rTianGanID;
                sTianGan = TianGan[rTianGanID];
            }
            else if (GuaZhu.nQiGuaHour == 5 || GuaZhu.nQiGuaHour == 6)
            {
                rTianGanID = 3 + rTianGanID;
                rTianGanID = rTianGanID > 9 ? (rTianGanID - 10) : rTianGanID;
                sTianGan = TianGan[rTianGanID];
            }
            else if (GuaZhu.nQiGuaHour == 7 || GuaZhu.nQiGuaHour == 8)
            {
                rTianGanID = 4 + rTianGanID;
                rTianGanID = rTianGanID > 9 ? (rTianGanID - 10) : rTianGanID;
                sTianGan = TianGan[rTianGanID];
            }
            else if (GuaZhu.nQiGuaHour == 9 || GuaZhu.nQiGuaHour == 10)
            {
                rTianGanID = 5 + rTianGanID;
                rTianGanID = rTianGanID > 9 ? (rTianGanID - 10) : rTianGanID;
                sTianGan = TianGan[rTianGanID];
            }
            else if (GuaZhu.nQiGuaHour == 11 || GuaZhu.nQiGuaHour == 12)
            {
                rTianGanID = 6 + rTianGanID;
                rTianGanID = rTianGanID > 9 ? (rTianGanID - 10) : rTianGanID;
                sTianGan = TianGan[rTianGanID];
            }
            else if (GuaZhu.nQiGuaHour == 13 || GuaZhu.nQiGuaHour == 14)
            {
                rTianGanID = 7 + rTianGanID;
                rTianGanID = rTianGanID > 9 ? (rTianGanID - 10) : rTianGanID;
                sTianGan = TianGan[rTianGanID];
            }
            else if (GuaZhu.nQiGuaHour == 15 || GuaZhu.nQiGuaHour == 16)
            {
                rTianGanID = 8 + rTianGanID;
                rTianGanID = rTianGanID > 9 ? (rTianGanID - 10) : rTianGanID;
                sTianGan = TianGan[rTianGanID];
            }
            else if (GuaZhu.nQiGuaHour == 17 || GuaZhu.nQiGuaHour == 18)
            {
                rTianGanID = 9 + rTianGanID;
                rTianGanID = rTianGanID > 9 ? (rTianGanID - 10) : rTianGanID;
                sTianGan = TianGan[rTianGanID];
            }
            else if (GuaZhu.nQiGuaHour == 19 || GuaZhu.nQiGuaHour == 20)
            {
                rTianGanID = 10 + rTianGanID;
                rTianGanID = rTianGanID > 9 ? (rTianGanID - 10) : rTianGanID;
                sTianGan = TianGan[rTianGanID];
            }
            else if (GuaZhu.nQiGuaHour == 21 || GuaZhu.nQiGuaHour == 22)
            {
                rTianGanID = 11 + rTianGanID;
                rTianGanID = rTianGanID > 9 ? (rTianGanID - 10) : rTianGanID;
                sTianGan = TianGan[rTianGanID];
            }
        }
        public static void GetsGanZhi()
        {
            if (rTianGan == " a " || rTianGan == " f ")
            {
                rTianGanID = 0;
                GetShiGan();
            }
            else if (rTianGan == " b " || rTianGan == " heptyl ")
            {
                rTianGanID = 2;
                GetShiGan();
            }
            else if (rTianGan == " c " || rTianGan == " simba ")
            {
                rTianGanID = 4;
                GetShiGan();
            }
            else if (rTianGan == " ding " || rTianGan == " nonyl ")
            {
                rTianGanID = 6;
                GetShiGan();
            }
            else
            {
                rTianGanID = 8;
                GetShiGan();
            }
            if (GuaZhu.nQiGuaHour == 23 || GuaZhu.nQiGuaHour == 0)
            {
                sDiZhi = DiZhi[0];
            }
            if (GuaZhu.nQiGuaHour == 1 || GuaZhu.nQiGuaHour == 2)
            {
                sDiZhi = DiZhi[1];
            }
            if (GuaZhu.nQiGuaHour == 3 || GuaZhu.nQiGuaHour == 4)
            {
                sDiZhi = DiZhi[2];
            }
            if (GuaZhu.nQiGuaHour == 5 || GuaZhu.nQiGuaHour == 6)
            {
                sDiZhi = DiZhi[3];
            }
            if (GuaZhu.nQiGuaHour == 7 || GuaZhu.nQiGuaHour == 8)
            {
                sDiZhi = DiZhi[4];
            }
            if (GuaZhu.nQiGuaHour == 9 || GuaZhu.nQiGuaHour == 10)
            {
                sDiZhi = DiZhi[5];
            }
            if (GuaZhu.nQiGuaHour == 11 || GuaZhu.nQiGuaHour == 12)
            {
                sDiZhi = DiZhi[6];
            }
            if (GuaZhu.nQiGuaHour == 13 || GuaZhu.nQiGuaHour == 14)
            {
                sDiZhi = DiZhi[7];
            }
            if (GuaZhu.nQiGuaHour == 15 || GuaZhu.nQiGuaHour == 16)
            {
                sDiZhi = DiZhi[8];
            }
            if (GuaZhu.nQiGuaHour == 17 || GuaZhu.nQiGuaHour == 18)
            {
                sDiZhi = DiZhi[9];
            }
            if (GuaZhu.nQiGuaHour == 19 || GuaZhu.nQiGuaHour == 20)
            {
                sDiZhi = DiZhi[10];
            }
            if (GuaZhu.nQiGuaHour == 21 || GuaZhu.nQiGuaHour == 22)
            {
                sDiZhi = DiZhi[11];
            }
        }
        public static void GetSiZhu()
        {
            GetnGanZhi();
            GetyGanZhi();
            GetrGanZhi();
            GetsGanZhi();
            sSiZhu = nTianGan + nDiZhi + " " + yTianGan + yDiZhi + " ";
            sSiZhu += rTianGan + rDiZhi + " " + sTianGan + sDiZhi;
            string birthday;
            birthday = nQiGuaYear + " years " + nQiGuaMonth + " month " + nQiGuaDay + " day " + nQiGuaHour + " when " + nQiGuaMinute + " points ";
            Console.WriteLine(" Gregorian calendar time of birth :" + birthday);
            Console.WriteLine(" before 1 Solar term is " + NextJieQi);
            Console.WriteLine(" after 1 Solar term is " + PrevJieQi);
            Console.WriteLine(" Life are the main 8 Words are :" + sSiZhu);
            Console.WriteLine(" Please press any key to continue ...");
            Console.ReadKey();
        }
    }
}

The above is all the content of the code to share with you in this article. I hope you can enjoy it and help you to learn C#.


Related articles: