?? quicksorter.java
字號:
//
// This class sorts an array using the QuickSort method.
public class QuickSorter
{
private int[] a;
public QuickSorter(int[] anArray)
{
a=anArray;
}
public void sort(int from, int to)
{
if (from>=to)
return;
int p = partition(from,to);
sort(from,p);
sort(p+1,to);
}
private int partition(int from, int to)
{
int temp;
int pivot = a[from];
int i = from-1;
int j = to +1;
while(i<j)
{
i++;
while (a[i]<pivot)
i++;
j--;
while(a[j]>pivot)
j--;
if(i<j)
{
temp = a[i];
a[i] = a[j];
a[j] = temp;
}
}
return j;
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -