数组的冒泡排序方法
口訣:n個數字來排列兩兩比較小靠前,外層循環n-1內層循環n-i-1
public static int[] bubbleSort(int[] arr){for(int i=0;i<arr.length-1;i++){for(int j=0;j<arr.length-i-1;j++){if(arr[j]>arr[j+1]){int temp=arr[j];arr[j]=arr[j+1];arr[j+1]=temp;}}}return arr;?
轉載于:https://www.cnblogs.com/yuchenjing/p/8994850.html
總結
- 上一篇: Box-Cox(python实现)
- 下一篇: [转]springmvc常用注解标签详解