static void Main(string[] args) { int[] num = new int[] { 5, 7, 8, 3, 2, 9, 6, 4, 10, 1 }; QuickSort(num, 0, num.Length - 1); for (int i = 0; i < num.Length; i++) { Console.Write(num[i] + " "); } Console.ReadKey(); } public static void QuickSort(int[] num, int start, int end) { if (start >= end) return; int startNum = start, endNum = end; int a = num[startNum]; while (endNum > startNum) { while (endNum > startNum && num[endNum]>a ) { endNum--; } num[startNum] = num[endNum]; while (endNum > startNum &&a>num[startNum]) { startNum++; } num[endNum] = num[startNum]; } num[startNum] = a; QuickSort(num, start, startNum - 1); QuickSort(num, startNum + 1, end); }