标签:排序 code div ble 经典 ring [] 算法 str
1 /** 2 *冒泡排序(当前值与下一个值依次比较) 3 */ 4 public class BubbleSort 5 { 6 public static void main(String[] args) 7 { 8 sort(); 9 } 10 public static void sort(){ 11 12 int[] arr = new int[]{80,15,31,20,59}; 13 14 for(int i=1;i<arr.length;i++){ 15 for(int j=0;j<arr.length-i;j++){ 16 if(arr[j]>arr[j+1]){ 17 int temp =arr[j]; 18 arr[j] =arr[j+1]; 19 arr[j+1] =temp; 20 } 21 } 22 } 23 for(int i=0;i<arr.length;i++){ 24 System.out.println(arr[i]); 25 } 26 27 } 28 }
标签:排序 code div ble 经典 ring [] 算法 str
原文地址:https://www.cnblogs.com/zhangningning/p/9510930.html