Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
quick sort
//Rextester.Program.Main is the entry point for your code. Don't change it. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5 using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace sortQuick { class quickSort { private int[] array = new int[20]; private int len; public void QuickSort() { sort(0, len - 1); } public void sort(int left, int right) { int pivot, leftend, rightend; leftend = left; rightend = right; pivot = array[left]; while (left < right) { while ((array[right] >= pivot) && (left < right)) { right--; } if (left != right) { array[left] = array[right]; left++; } while ((array[left] <= pivot) && (left < right)) { left++; } if (left != right) { array[right] = array[left]; right--; } } array[left] = pivot; pivot = left; left = leftend; right = rightend; if (left < pivot) { sort(left, pivot - 1); } if (right > pivot) { sort(pivot + 1, right); } } public static void Main() { quickSort q_Sort = new quickSort(); int[] array = { 4, 3, 1, 4, 6, 7, 5, 4, 32, 5, 26, 187, 8 }; q_Sort.array = array; q_Sort.len = q_Sort.array.Length; q_Sort.QuickSort(); for (int j = 0; j < q_Sort.len; j++) { Console.WriteLine(q_Sort.array[j]); } Console.ReadKey(); } } }
run
|
edit
|
history
|
help
0
tokenExchange
Practicando C#
amstrong number
Array Comparison
фабрика статик
Dictionary that tells which key was not present
Get Combined Placeholder Settings and New Content Length
Cenforce 100 mg
enums with extension method: better
FizzBuzz Solution