冒泡排序分析 代码1234567891011121314151617181920212223242526package 算法;public class 冒泡排序 { public static void main(String[] args) { int[] arr = new int[]{3,9,-1,10,20}; int len = arr.length; boolean flag = true; for (int i = 0; i < len-1; i++) { flag = true; for (int j = i+1; j < len-1-i; j++) { if(arr[i]>arr[j]){ int temp = arr[i]; arr[i] = arr[j]; arr[j] = temp; flag =false; } } if(flag){ break; } } for (int i : arr) { System.out.println(i); } }}