[原创]冒泡排序BubbleSort Virus

 public class BubbleSort
    {
        private int [] mylist;

        public BubbleSort()
        {
            mylist = new int[12] { 19, 13, 5, 27, 1, 26, 31, 16, 2, 9, 11, 21 };
        }
        public void Pad()
        {
           
           
        }
        public void StartSort()
        {
            int temp = 0;
            int f = mylist.Length-1;
            for (int i = 0; i < f; i++)
            {
                int k = 0;
                for (int j = k; j < f - k; j++)
                {
                    if (mylist[j] > mylist[j + 1])
                    {
                        temp = mylist[j];
                        mylist[j] = mylist[j + 1];
                        mylist[j + 1] = temp;
                    }
                }
            }
        }
        public void Display()
        {
            for (int i = 0; i < mylist.Length; i++)
            {
                Console.WriteLine(mylist[i]);
            }
        }
      
       
    }
class Program
    {
        static void Main(string[] args)
        {
            BubbleSort bb = new BubbleSort();

            bb.StartSort();
            bb.Display();
            Console.ReadLine();
        }
    }

【Blog】http://virusswb.cnblogs.com/

【MSN】jorden008@hotmail.com

【说明】转载请标明出处,谢谢

反馈文章质量,你可以通过快速通道评论:

原文地址:https://www.cnblogs.com/virusswb/p/852440.html