Esempio n. 1
0
        /// <summary>
        /// 生成注册码
        /// </summary>
        /// <returns></returns>
        public static string getRNumWithDate(DateTime date, string computerCode = null)
        {
            intCode   = new int[127];
            intNumber = new int[33];
            Charcode  = new char[33];

            setIntCode();            //初始化127位数组
            string MNum = getMNum(); //获取注册码

            if (!string.IsNullOrEmpty(computerCode))
            {
                MNum = computerCode;
            }
            MNum += date.ToString("yyyyMMdd");

            if (MNum.Length != Charcode.Length - 1)
            {
                return(null);
            }

            for (int i = 1; i < Charcode.Length; i++)//把机器码存入数组中
            {
                Charcode[i] = Convert.ToChar(MNum.Substring(i - 1, 1));
            }
            for (int j = 1; j < intNumber.Length; j++)//把字符的ASCII值存入一个整数组中。
            {
                intNumber[j] = intCode[Convert.ToInt32(Charcode[j])] + Convert.ToInt32(Charcode[j]);
            }
            string strAsciiName = "";//用于存储注册码

            for (int j = 1; j < intNumber.Length; j++)
            {
                var code = intNumber[j] + (j % 3);

                if (code >= 48 && code <= 57)//判断字符ASCII值是否0-9之间
                {
                    strAsciiName += Convert.ToChar(code).ToString();
                }
                else if (code >= 65 && code <= 90)//判断字符ASCII值是否A-Z之间
                {
                    strAsciiName += Convert.ToChar(code).ToString();
                }
                else if (code >= 97 && code <= 122)//判断字符ASCII值是否a-z之间
                {
                    strAsciiName += Convert.ToChar(code).ToString();
                }
                else//判断字符ASCII值不在以上范围内
                {
                    if (code > 122)//判断字符ASCII值是否大于z
                    {
                        strAsciiName += Convert.ToChar(code - 10).ToString();
                    }
                    else
                    {
                        strAsciiName += Convert.ToChar(code - 9).ToString();
                    }
                }
            }
            return(strAsciiName);//返回注册码
        }
Esempio n. 2
0
        List <MNum> Sums(Dictionary <int, MNum> dbrB, List <double> bi)
        {
            var ret = new List <MNum>();

            for (int i = 0; i < eq[0].Count; i++)
            {
                MNum s = new MNum();
                for (int j = 0; j < rows; j++)
                {
                    s += eq[j][i] * dbrB.Values.ToArray()[j];
                }
                s += new MNum(-f.eq[i], 0);
                ret.Add(s);
            }
            MNum bis = new MNum();

            for (int j = 0; j < rows; j++)
            {
                bis += bi[j] * dbrB.Values.ToArray()[j];
            }
            ret.Add(bis);
            ret.Add(new MNum());
            return(ret);
        }