每种语言都有冒泡JAVA实现如下:

    public static  void  main(String args[]){
        System.out.println("Start");
        int[] sort ={5,2,6,8,3,1,9,0,4};
        Sort(sort);
        System.out.println("End");
    }

    public static int[] Sort(int[] sort){
        for (int i=0;i<sort.length-1;i++){
            for (int j=0;j<sort.length-1;j++){
                if(sort[j]>sort[j+1]){
                    int temp = sort[j];
                    sort[j] = sort[j+1];
                    sort[j+1] = temp;
                }
            }
        }
        return sort;
    }

 

相关文章:

猜你喜欢
  • 2021-09-13
  • 2021-08-01
  • 2021-09-30
  • 2022-02-13
  • 2021-10-04
  • 2021-07-01
  • 2021-10-26
相关资源
相似解决方案