import java.util.Arrays;
public class QuickSort
{
public static void sort(int array[], int low, int high)
{
int l = low;
int h = high;
int k = array[low];
while (l < h)
{
while (l < h && array[h] >= k)
{
h--;
}
if (l < h)
{
int temp = array[h];
array[h] = array[l];
array[l] = temp;
l++;
}
while (l < h && array[l] <= k)
{
l++;
}
if (l < h)
{
System.out.println(Arrays.toString(array));;
System.out.print("第"+(l+1)+"号和第"+(h+1)+"号交换位置-----");
System.out.println(" l=" + array[l] + " h=" + array[h] + " k=" + k);
本内容试读结束,登录后可阅读更多
下载后可阅读完整内容,剩余1页未读,立即下载