public int[] Sort(ArrayTestBed arrayObject)
        {
            int minimumValueIndex, tempValue;
            var numberArray = arrayObject.arr;

            for (int i = 0; i <= arrayObject.upper; ++i)
            {
                minimumValueIndex = i;
                for (int j = i + 1; j <= arrayObject.upper; ++j)
                {
                    if (numberArray[j] > numberArray[minimumValueIndex])
                    {
                        minimumValueIndex = j;
                    }
                }

                tempValue      = numberArray[i];
                numberArray[i] = numberArray[minimumValueIndex];
                numberArray[minimumValueIndex] = tempValue;

                if (ShowLog)
                {
                    arrayObject.DispayElements();
                }
            }
            return(numberArray);
        }
        public int[] ReverseSort(ArrayTestBed arrayObject)
        {
            int tempValue;
            var numberArray = arrayObject.arr;
            int j;

            for (int i = 0; i <= arrayObject.upper; i++)
            {
                tempValue = numberArray[i];
                j         = i;
                while (j > 0 && numberArray[j - 1] < tempValue)
                {
                    numberArray[j] = numberArray[j - 1];
                    --j;
                }
                numberArray[j] = tempValue;
                if (ShowLog)
                {
                    arrayObject.DispayElements();
                }
            }
            return(numberArray);
        }
示例#3
0
        public int[] ReverseSort(ArrayTestBed testBed)
        {
            int temp;
            var arrayObject = testBed.arr;

            for (int i = testBed.upper; i > 0; i--)
            {
                for (int j = 0; j < i; ++j)
                {
                    if (arrayObject[j] < arrayObject[j + 1])
                    {
                        temp               = arrayObject[j];
                        arrayObject[j]     = arrayObject[j + 1];
                        arrayObject[j + 1] = temp;
                    }
                }

                if (ShowLog)
                {
                    testBed.DispayElements();
                }
            }
            return(arrayObject);
        }