示例#1
0
文件: StrHelper.cs 项目: cfmis/cfw
        /// <summary>
        /// 格式化占用空间大小的输出
        /// </summary>
        /// <param name="size">大小</param>
        /// <returns>返回 String</returns>
        public static string FormatNUM(long size)
        {
            #region
            decimal NUM;
            string  strResult;

            if (size > 1073741824)
            {
                NUM       = (Convert.ToDecimal(size) / Convert.ToDecimal(1073741824));
                strResult = NUM.ToString("N") + " M";
            }
            else if (size > 1048576)
            {
                NUM       = (Convert.ToDecimal(size) / Convert.ToDecimal(1048576));
                strResult = NUM.ToString("N") + " M";
            }
            else if (size > 1024)
            {
                NUM       = (Convert.ToDecimal(size) / Convert.ToDecimal(1024));
                strResult = NUM.ToString("N") + " KB";
            }
            else
            {
                strResult = size + " 字节";
            }

            return(strResult);

            #endregion
        }
示例#2
0
        /// <summary>【通用函数】取得金额某位的大写</summary>
        /// <param name="Value">数字</param>
        /// <param name="B">位置,-2分-1角0元1十2百3千4万,以此类推</param>
        /// <returns>返回数字,如:贰</returns>
        public static string MoneyBitUpper(double Value, int B)
        {
            const string NUM = "零壹贰叁肆伍陆柒捌玖";
            string       S   = "";
            double       d   = StrToDouble(Value.ToString("0.00"));

            if (d < 0)
            {
                S = "负";
                d = -d;
            }
            int P = (int)(d / Math.Pow(10, B) + 0.001);

            if (P == 0)
            {
                return("¤");
            }
            else
            {
                if (P >= 10)
                {
                    S = "";
                }
                P = P % 10;
                return(S + NUM.Substring(P, 1));
            }
        }
示例#3
0
    /// <summary>
    /// 小雞跳躍方法。
    /// </summary>
    private void Jump()
    {
        if (dead == true)
        {
            return;     //程式跳出這個{}外因此跳過JUMP
        }

        //if (dead) return;   簡寫{}內只有一行敘述 {}可將其省略


        //如果玩家按下左鍵
        //輸入按下按鍵.手機觸控

        if (Input.GetKeyDown(KeyCode.Mouse0))
        {
            //print("0000");
            aud.PlayOneShot(SE_Jump, 1.5f);
            r2d.Sleep();                        //小雞剛體重新設定
            r2d.gravityScale = 1;               //小雞剛體,重力 = 1;
            r2d.AddForce(new Vector2(0, jump)); //小雞剛體.增加推力(二維向量(左右,上下));
            //分數 顯示
            //GM 顯示
            GM.SetActive(true);
            NUM.SetActive(true);
        }
        r2d.SetRotation(angle * r2d.velocity.y);
        //Rigidbody2D.SetRotation(float)設定角度(角度)
        //Rigidbody2D.velocity 加速度(二維向量x,y)

        //小雞 往上跳
    }
示例#4
0
        private void CheckForVariableChange(string[] tokens)
        {
            if (!IsNumVar(tokens[0]))
            {
                return;
            }

            int numIndex = GetNumIndex(tokens[0]);

            //Check for var++ and var--
            if (IsNumVar(tokens[0]) && tokens.Length == 1 && tokens[0].EndsWith("++"))
            {
                ChangeNUMValue(nums[numIndex], numIndex, true, 1.0f);
                return;
            }
            else if (IsNumVar(tokens[0]) && tokens.Length == 1 && tokens[0].EndsWith("--"))
            {
                ChangeNUMValue(nums[numIndex], numIndex, false, 1.0f);
                return;
            }

            for (int i = 0; i < tokens.Length; ++i) //Skip first two tokens since they are not part of the new value
            {
                if (IsNumVar(tokens[i]))
                {
                    tokens[i] = nums[GetNumIndex(tokens[i])].value.ToString();
                }
            }

            string equation = string.Empty;

            if (tokens[1] == "=")
            {
                equation = string.Join(" ", tokens, 2, tokens.Length - 2);
            }
            else
            {
                equation = string.Join(" ", tokens);
            }

            float answer = Convert.ToSingle(dt.Compute(equation, ""));

            nums[numIndex] = new NUM {
                name = nums[numIndex].name, value = answer
            };

            file.CopyTo(lines, 0); //Reset the lines array to default
        }
示例#5
0
        private void ChangeNUMValue(NUM number, int index, bool add, float change)
        {
            float newValue = 0.0f;

            if (add == true)
            {
                newValue = number.value + change;
            }
            else
            {
                newValue = number.value - change;
            }

            nums[index] = new NUM {
                name = number.name, value = newValue
            };
            file.CopyTo(lines, 0); //Reset the file each iteration
        }
        static void Main(string[] args)
        {
            int    NUM, inv, DEC, UNI;
            string entrada;

            Console.WriteLine("INEVERTIR UN NUMERO DE DOS DIGITOS");
            Console.WriteLine("---------------------------------------");
            Console.WriteLine();
            Console.Write("escriba un numero de dos digitos:");
            entrada = Console.ReadLine();
            NUM     = int.Parse(entrada);
            DEC     = NUM / 10;
            UNI     = NUM % 10;
            inv     = (UNI * 10) + DEC;

            Console.WriteLine("");
            Console.WriteLine("el numero " + NUM.ToString() + " invertido es " + inv.ToString());
            Console.WriteLine();
            Console.WriteLine("pulse una tecla para salir...");
            Console.ReadKey();
        }
示例#7
0
        static void Main(string[] args)
        {
            const string NAME    = "BARLAN 123456789";
            const string VOWEL   = "AEIOU";
            const string NUM     = "0123456789";
            const string SURNAME = "URIZARTORRICO";


            foreach (var surname in SURNAME)
            {
                if (VOWEL.IndexOf(surname) >= 0)
                {
                    Console.WriteLine("The letter " + surname + " is vowel");
                }
                else if (NUM.IndexOf(surname) >= 0)
                {
                    Console.WriteLine("The names of the persons not content numbers ");
                }
                else
                {
                    Console.WriteLine("The letter " + surname + " is a consonat");
                }
            }
            foreach (var name in NAME)
            {
                if (NUM.IndexOf(name) >= 0)
                {
                    Console.WriteLine(name + " People's name doesn't have  a number");
                }
                else if (NAME.IndexOf(name) >= 0)
                {
                    Console.WriteLine();
                }
                else
                {
                    Console.WriteLine("The letter " + name + " is a consonat");
                }
            }
        }
示例#8
0
        ///// <summary>【通用函数】FONT转STRING
        ///// </summary>
        //public static string FontToStr(Font aFont)
        //{
        //    FontConverter fc = new FontConverter();
        //    return fc.ConvertToInvariantString(aFont);
        //}

        ///// <summary>【通用函数】STRING转FONT
        ///// </summary>
        //public static Font StrToFont(string aStr)
        //{
        //    FontConverter fc = new FontConverter();
        //    Font f = (Font)fc.ConvertFromString(aStr);
        //    return f;
        //}

        /// <summary>【通用函数】金额小写转换成大写</summary>
        /// <param name="Value">数字</param>
        /// <param name="AState">状态,true表示完整,false表示简写</param>
        /// <returns>返回字符串,如:叁佰贰拾伍元整</returns>
        public static string MoneyToUpper(double Value, bool AState)
        {
            const string NUM = "零壹贰叁肆伍陆柒捌玖";
            const string WEI = "分角元拾佰仟万拾佰仟亿拾佰仟";
            string       F   = "";
            double       d   = StrToDouble(Value.ToString("0.00"));

            if (AState)
            {
                if (d < 0)
                {
                    d = -d;
                    F = "负";
                }
                else if (d == 0)
                {
                    F = "零元零角零分";
                }
                else
                {
                    F = "";
                }
                int    L   = (int)Math.Truncate(Math.Log(d, 10));
                string Str = "";
                for (int i = L; i >= -2; i--)
                {
                    Int64 T = (Int64)(Math.Round(d, 2) / Math.Pow(10, i) + 0.000001);
                    int   N = (int)(T % 10);
                    Str = Str + NUM.Substring(N, 1) + WEI.Substring(i + 2, 1);
                }
                Str = F + Str;
                return(Str);
            }
            else
            {
                if (d < 0)
                {
                    d = -d;
                    F = "负";
                }
                else if (d == 0)
                {
                    F = "零元整";
                }
                else
                {
                    F = "";
                }
                int    L    = (int)(Math.Floor(Math.Log(d + 0.0000001, 10)));
                string Str  = "";
                bool   Zero = false; //上一位是不是0
                for (int i = L; i >= -2; i--)
                {
                    Int64 T = (Int64)(Math.Round(d, 2) / Math.Pow(10, i) + 0.000001);
                    int   N = (int)(T % 10);
                    if (N == 0)
                    {
                        if (i == 0 || i == 4 || i == 8) //碰到元、万、亿必须显示
                        {
                            Str  = Str + WEI.Substring(i + 2, 1);
                            Zero = false;
                        }
                        else
                        {
                            Zero = true;
                        }
                    }
                    else
                    {
                        if (Zero)
                        {
                            Str = Str + NUM.Substring(0, 1);
                        }
                        Str  = Str + NUM.Substring(N, 1) + WEI.Substring(i + 2, 1);
                        Zero = false;
                    }
                    if (Math.Abs(d - T * Math.Pow(10, i)) < 0.001 && i > -2 && i < 5)
                    {
                        if (i > 0)
                        {
                            Str = Str + "元整";
                        }
                        else
                        {
                            Str = Str + "整";
                        }
                        break;
                    }
                }
                Str = F + Str;
                return(Str);
            }
        }