import java
import java
import javax
import javax
public class Text {
private static Random rd;
private static int[] array;
public static void main(String[] args){
Random r = new Random();
array = new int[
ArrayList<Integer> list = new ArrayList<Integer>();
for(int i=
array = r
for(int i=
System
System
int l = Locate(array
for(int i=l; i<array
list
}
for(int i:list){
System
}
}
/*
用最快速的方法打亂一個數組
*/
private static void Resort(int[] array){
rd = new Random();
int temp;
for(int i=
int l = rd
//int m = rd
temp = array[
array[
array[l] = temp;
}
}
/*
給定一個數組
例如給定{
指定n=
將返回子數組{
*/
private static int Locate(int[] array
int[] list = new int[n];
int i=
int j=
for(i=
for(j=
list[j] = array[i+j];
if(list[j]>=c)
break;
}
if(j==n)
return i;
}
return
}
/*快速排序*/
private static void QuickSort(int[] array
int xx = x
int k = array[xx];
if(x>=y) return;
while(xx != yy){
while(xx<yy && array[yy]>=k) yy
array[xx] = array[yy];
while(xx<yy && array[xx]<=k) xx++;
array[yy] = array[xx];
}
array[xx] = k;
QuickSort(array
QuickSort(array
}
}
From:http://tw.wingwit.com/Article/program/sjjg/201405/30941.html