递归排序
static void Main(string[] args)
{
int[] array = new int[] {...........};
Print(array);//打印数组
Sort(array,0,array.Length-1);//排序
}
private void Print(int[] array)
{
for(int i =0; i <array.Lenght; i++)
{
Console.Write(array[i] + "\t");
}
Console.WriteLine();
}
private void Sort(int[] array, int start , int end)
{
int i = start;
int j = end;
int p = array[i];
while(i < j)
{
while(i< j && p <array[j])
{
j --;
}
array[i] = array[j];
while(i < j && p >array[i])
{
i ++;
}
array[j] = array[i];
array[i] = p;
if(i >start)
{
Sort(array,start,i -1);
}
if(i < end)
{
Sort(array,i +1, end);
}
}
}