我在浏览不同的quicksort实现时在网上找到了这个代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Quicksort
{
class Program
{
static void Main(string[] args)
{
// Create an unsorted array of string elements
string[] unsorted = { "z","e","x","c","m","q","a"};
// Print the unsorted array
for (int i = 0; i < unsorted.Length; i++)
{
Console.Write(unsorted[i] + " ");
}
Console.WriteLine();
// Sort the array
Quicksort(unsorted, 0, unsorted.Length - 1);
// Print the sorted array
for (int i = 0; i < unsorted.Length; i++)
{
Console.Write(unsorted[i] + …Run Code Online (Sandbox Code Playgroud)