28.冒泡排序

/*
 * 冒泡排序
 * */
public class SortNum {
    public static void main(String[] args) {
        int[] scores={16,25,9,90,23};
        for (int i = 0; i < scores.length -1 ; i++)
        {
              for (int j = 0; j < scores.length -1 - i ; j++)
              {
                    if (scores[j] > scores[j + 1])
                    { 
                          // 交换元素
                          int temp = scores[j];
                          scores[j] = scores[j + 1];
                          scores[j + 1] = temp;
                    }
              }
        }
        System.out.println("冒泡排序后:");
        for(int score:scores){
            System.out.print(score+"	");
        }
    }
}
原文地址:https://www.cnblogs.com/xiaotaoxu/p/5536339.html