随机数

public class TestRandom {
    public static void main(String[] args) {
        
        int a[]=new int[10];
        int temp;
        for (int i = 0; i < a.length; i++) {
            a[i]=(int)(Math.random()*100);
            
        }
        for (int i = 0; i < 10; i++) {
            for (int j = i+1; j < 10; j++) {
                if (a[i]>a[j]) {
                    temp=a[i];
                    a[i]=a[j];
                    a[j]=temp;
                }
            }
        }
        //for (int i = 0; i < 10; i++) {
            System.out.println(a[9]+" ");
        //}
    }
    
/*    Arrays.sort()Ҳ������*/
}
原文地址:https://www.cnblogs.com/lc-java/p/7359113.html