代码
public class QuickSort {
public static int[] QuickSort0(int[] pData, int left, int right) {
int i= left, j= right;
int middle, strTemp;
middle = pData[(left + right) / 2];
do {
while ((pData[i] < middle) && (i < right))
i++;
while ((pData[j] > middle) && (j > left))
j--;
if (i <= j) {
strTemp = pData[i];
pData[i] = pData[j];
pData[j] = strTemp;
i++;
j--;
}
} while (i <= j);
for (int t = 0; t < pData.length; t++)
System.out.print(pData[t] + " ");
System.out.println("");
if (left < j) {
QuickSort0(pData, left, j);
}
if (right > i)
QuickSort0(pData, i, right);
return pData;
}
public static void main(String[] argv) {
int[] pData = { 1,84, 85, 67,600, 88,999 };
QuickSort0(pData, 0, pData.length - 1);
}
}
public class QuickSort {
public static int[] QuickSort0(int[] pData, int left, int right) {
int i= left, j= right;
int middle, strTemp;
middle = pData[(left + right) / 2];
do {
while ((pData[i] < middle) && (i < right))
i++;
while ((pData[j] > middle) && (j > left))
j--;
if (i <= j) {
strTemp = pData[i];
pData[i] = pData[j];
pData[j] = strTemp;
i++;
j--;
}
} while (i <= j);
for (int t = 0; t < pData.length; t++)
System.out.print(pData[t] + " ");
System.out.println("");
if (left < j) {
QuickSort0(pData, left, j);
}
if (right > i)
QuickSort0(pData, i, right);
return pData;
}
public static void main(String[] argv) {
int[] pData = { 1,84, 85, 67,600, 88,999 };
QuickSort0(pData, 0, pData.length - 1);
}
}
public static int[] QuickSort0(int[] pData, int left, int right) {
int i= left, j= right;
int middle, strTemp;
middle = pData[(left + right) / 2];
do {
while ((pData[i] < middle) && (i < right))
i++;
while ((pData[j] > middle) && (j > left))
j--;
if (i <= j) {
strTemp = pData[i];
pData[i] = pData[j];
pData[j] = strTemp;
i++;
j--;
}
} while (i <= j);
for (int t = 0; t < pData.length; t++)
System.out.print(pData[t] + " ");
System.out.println("");
if (left < j) {
QuickSort0(pData, left, j);
}
if (right > i)
QuickSort0(pData, i, right);
return pData;
}
public static void main(String[] argv) {
int[] pData = { 1,84, 85, 67,600, 88,999 };
QuickSort0(pData, 0, pData.length - 1);
}
}
public class QuickSort { public static int[] QuickSort0(int[] pData, int left, int right) { int i= left, j= right; int middle, strTemp; middle = pData[(left + right) / 2]; do { while ((pData[i] < middle) && (i < right)) i++; while ((pData[j] > middle) && (j > left)) j--; if (i <= j) { strTemp = pData[i]; pData[i] = pData[j]; pData[j] = strTemp; i++; j--; } } while (i <= j); for (int t = 0; t < pData.length; t++) System.out.print(pData[t] + " "); System.out.println(""); if (left < j) { QuickSort0(pData, left, j); } if (right > i) QuickSort0(pData, i, right); return pData; } public static void main(String[] argv) { int[] pData = { 1,84, 85, 67,600, 88,999 }; QuickSort0(pData, 0, pData.length - 1); } }