c# - 在C#中,快速排序算法

到目前为止的代码:


using System;


using System.Collections.Generic;


using System.Linq;


using System.Text;


using System.Threading.Tasks;



namespace quicksort


{


class Program


{


 static void Main(string[] args)


 {



 int n = 11; //11 values in array to have 0-10 index


 Random r = new Random();


 int[] a; //index 0 to 10


 a = new int[n];


 a[0] = 0;



 for (int i = 0; i < n; i++) //the array


 a[i] = r.Next(1, 100);



 Console.WriteLine("The original array is:");


 for (int i = 0; i < n; i++)


 {


 Console.Write(a[i] +"");



 }



 Console.WriteLine();



 int pivot = a[n / 2];



 Console.WriteLine("The pivot is:" + pivot);


 Console.Read();



 }


}


}



时间:

请参考下面给出的链接— https://www.geeksforgeeks.org/quick-sort/

...