Exemplo n.º 1
0
        public void Simple()
        {
            var unsorted = new[] { 0, 1, 20, 12, 30, 1, 33, 54, 6, 54503403 };

            var sorter = new SelSort();

            // sorter.Sort(unsorted);

            AssertIsSorted(unsorted);
        }
Exemplo n.º 2
0
        static void BSort(int[] Array, SelSort ss)
        {
            int i    = 0;
            int j    = 0;
            int temp = 0;

            for (i = 0; i < Array.Length - 1; i++)
            {
                for (j = 0; j < Array.Length - (i + 1); j++)
                {
                    if (ss(Array[j], Array[j + 1]) > 0)
                    {
                        temp         = Array[j];
                        Array[j]     = Array[j + 1];
                        Array[j + 1] = temp;
                    }
                }
            }
        }
Exemplo n.º 3
0
        // 버블 정렬 알고리즘
        // 원래 매개변수 int[] Array1
        static void BSort(int[] Array1, SelSort Ss)
        {
            int i    = 0; // 이중for문
            int j    = 0;
            int temp = 0; // 자리바꿈

            for (i = 0; i < Array1.Length - 1; i++)
            {
                for (j = 0; j < Array1.Length - (i + 1); j++)
                {
                    // 오른차순
                    //if(Array1[j] > Array1[j + 1])

                    if (Ss(Array1[j], Array1[j + 1]) > 0)
                    {
                        temp          = Array1[j];
                        Array1[j]     = Array1[j + 1];
                        Array1[j + 1] = temp;
                    }
                }
            }
        }