冒泡排序练习题

import java.util.*;

public class BubbleSort {
    public int[] bubbleSort(int[] a, int l) {
        // write code here
        for(int i = l-2;i>=0;i--){
            for(int j=0;j<=i;j++){
             if(a[j]>a[j+1]){
                 int temp = a[j] ;
                 a[j] = a[j+1];
                 a[j+1] = temp;
             } 
              
            }
        }
        return a;
    }
}

你可能感兴趣的:(剑指offer)