C#控制台吹泡泡算法

代码如下:

        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

你可能感兴趣的:(C#控制台吹泡泡算法)