C#コンソールブローバブルアルゴリズム

1120 ワード

コードは次のとおりです.
        static void Main(string[] args)
        {
            Bubbling(100, 100, "O", 1000);
            Console.ReadLine();
        }

        /// 
        ///   
        /// 
        ///   
        ///   
        ///     
        ///         
        static void Bubbling(int height,int width,string type,int time) 
        {
            List list = new List();
            for (int i = height; i > 0;i-- )
            {
                Console.Clear();
                int ran = new Random().Next(0, width);
                string str = string.Empty;
                for (int j = 0; j < ran; j++) str += " ";
                list.Add(str+ type);
                for (int k = 0; k < i; k++) Console.WriteLine();
                foreach (string item in list) Console.WriteLine(item);
                System.Threading.Thread.Sleep(time);
            }
        }

 
転載先:https://www.cnblogs.com/myesn/p/5601615.html