第2个回答 2020-05-10
public class test { /** * @param args */ public static void main(String[] args) { int[] a = { 5, 3, 1, 2, 4, 6 }; a = bubbleSort(a); for (int i = 0; i < a.length; i++) { System.out.println(a[i]); } } public static int[] bubbleSort(int[] args) { for (int i = 0; i < args.length - 1; i++) { for (int j = i + 1; j < args.length; j++) { if (args[i] < args[j]) { int temp = args[i]; args[i] = args[j]; args[j] = temp; } } } return args; } }本回答被网友采纳