java冒泡排序法

import java.util.Arrays;

public class Maopao
{
    public static void main(String[]args)
    {
        int[] arr={3,35,572,4,57,11,234,3245};
        System.out.println(Arrays.toString(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;
                }
            }
        }
        System.out.println(Arrays.toString(arr));
    }
}


你可能感兴趣的:(java)