• 小程序--冒泡排序


    //冒泡排序:相邻两个比较,选出最大的往后放
    class Alhh{
    public static void main(String[] args){
    int[] m=new int[]{-3,12,4,15,-99};
    for(int i=0;i<m.length-1;i++){
    for(int j=0;j<m.length-1-i;j++){
    if(m[j]>m[j+1]){
    int temp=m[j];
    m[j]=m[j+1];
    m[j+1]=temp;
    }
    }

    }
    for(int i=0;i<m.length;i++){
    System.out.print(m[i]+" ");
    }
    }
    }

  • 相关阅读:
    编程学习杂烩
    设计模式
    redis
    H5
    Java
    db工具
    python + pip
    mysql
    Spring Security
    Spring Cloud Gateway
  • 原文地址:https://www.cnblogs.com/alhh/p/5287687.html
Copyright © 2020-2023  润新知