给定一个整数数组 nums
,将该数组升序排列。
示例 1:
输入:[5,2,3,1] 输出:[1,2,3,5]
示例 2:
输入:[5,1,1,2,0,0] 输出:[0,0,1,1,2,5]
public static void main(String[] args) {
int [] array={4,8,6,9,7,1,3,2,5};
if(array==null||array.length<=1){
return;
}
quickSort(array,0,array.length-1);
for (int m=0;m<array.length;m++){
System.out.println(array[m]);
}
}
public static void quickSort(int[] array,int left,int right){
if(left>right){
return ;
}
int i=left;
int j=array.length-1;
int base=array[left];//基准数据
while(i!=j){//相等终止条件
while(i<j&&array[j]>=base){ //从右边找到比base小的数据
j--;
}
while(i<j&&array[i]<=base){ //从左边找到比base大的数据
i++;
}
if(i<j){ //交换彼此的位置
int temp=array[i];
array[i]=array[j];
array[j]=temp;
}
}
//基准数据归位
array[left]= array[i];
array[i]=base;
//分别从左右两边 再次排序
quickSort(array,left,i-1);
quickSort(array,i+1,right);
}
Cialis Precio Farmacia Espana https://acialisd.com/ – buy cialis without prescription Generique Cialis Net Cialis Best Online Propecia Reviews
Baclofen Vente Wicmymmele https://artsocialist.com/ – Cialis gaideleplete Nolvadex Testosterone affextop Cialis adoreakder Viagra Online Gunstig
lasix without a script
buy cialis online without a prescription
viagra vs cialis vs levitra reviews
cialis cost