数组从小到大排序
//数组从小到大排序 int[] arr = {1,3,2,4,5}; Arrnum(arr);
private static void Arrnum(int[] arr) { int len = arr.length; for (int i=0;i < len;i++){ for (int n=0;n <len-1-i;n++) if (arr[n] < arr[n+1]){ } else { int temp = arr[n]; arr[n] = arr[n+1]; arr[n+1] = temp; } } System.out.println("排序后为:"+ Arrays.toString(arr)); }
本文来自博客园,作者:xiaoyongdata(微信号:xiaoyongdata),转载请注明原文链接:https://www.cnblogs.com/xiaoyongdata/p/16267445.html