public final static void swap(int a[],int i,int j){  
        int temp = a[i];  
        a[i] = a[j];  
        a[j] = temp;  
    }  
    public static void bubbleSort(int a[]){  
        bubbleSort(a,0,a.length);  
    }  
    public static void bubbleSort(int a[],int low,int high){  
        for(int i = high; --i > low;){  
            for(int j = low; ++j <= i; ){  
                if(a[j]>a[j-1]){  
                    swap(a,j,j-1);  
                }  
            }  
        }  
    }  
    public static void insertSort(int a[]){  
        insertSort(a,0,a.length);  
    }  
    public static void insertSort(int a[],int low,int high){  
        for(int i = low; ++i < high; ){    
            int j = i,key = a[i];  
            while( --j >= low&&a[j]<key){               
                a[j+1]=a[j];                  
            }     
            a[j+1] = key;             
        }  
    }  
    public static void selectSort(int a[],int low,int high){  
        for(int i = high;--i>low;){  
            int max = i;  
            for(int j = i;--j>=low;){  
                if(a[j]>a[max])max=j;  
            }  
            swap(a,max,i);  
        }  
    }  
    public static void selectSort(int a[]){  
        selectSort(a,0,a.length);  
    }  
个人网站  
www.software8.co