package com.zyf.day24;
import java.util.Arrays;
public class MaoPao {
public static void main(String[] args) {
// TODO Auto-generated method stub
int[] arr = {2,5,3,8,9,6};
for(int j = 0;j < arr.length - 1;j++){
for(int i = 0;i < arr.length-1-j;i++){
if(arr[i] > arr[i+1]){
int temp = arr[i];
arr[i] = arr[i+1];
arr[i+1] = temp;
}
}
}
System.out.println(Arrays.toString(arr));
}
}
冒泡算法
最新推荐文章于 2020-10-29 09:40:33 发布