第七次上机

public class fff {

    public static void main(String[] args) {
        int[] a = new int[]{1, 3, 2, 5, 8};
        int t;
        for (int i = 0; i < a.length - 1; i++) {
            for (int j = 0; j < a.length - 1 - i; j++) {
                if (a[j + 1] > a[j]) {
                    t = a[j];
                    a[j] = a[j + 1];
                    a[j + 1] = t;
                }
            }
        }
        double sum=0;
        for (int k = 1; k <a.length-1 ; k++) {
            sum+=a[k];
        }
        System.out.println("平均分"+sum/(a.length-2));
    }
}
import java.util.Random;

public class fff {

    public static void main(String[] args) {
        int[] a = new int[10];
        Random r=new Random();
        for (int i = 0; i < a.length; i++) {
            a[i]=r.nextInt(100);
        }
        int t;
        for (int i = 0; i < a.length - 1; i++) {
            for (int j = 0; j < a.length-1-i; j++) {
                if (a[j + 1] > a[j]) {
                    t = a[j];
                    a[j] = a[j + 1];
                    a[j + 1] = t;
                }
            }
        }
        for (int i : a) {
            System.out.println(i);
        }

    }
}
import java.util.Random;

public class fff {

    public static void main(String[] args) {
        int[] a = new int[35];
        Random r=new Random();
        for (int i = 0; i < a.length; i++) {
            a[i]=r.nextInt(34)+1;
        }
        int[] b=new int[7];
        for (int j = 0; j < 7; j++) {
            b[j]=a[r.nextInt(36)];
        }
        for (int i : b) {
            System.out.print(i+",");
        }
    }
}
ublic class fff {

    public static void main(String[] args) {
        int[] a = new int[]{2,3,52,3,69,58,46,12,53,27};
        int max=a[0];
        int mini=a[0];
        int jishu=0;
        int oushu=0;
        for (int i = 1; i <a.length ; i++) {
            if (a[i]>max){
                max=a[i];
            }
        }
        for (int j = 1; j <a.length ; j++) {
            if (a[j]<mini){
                mini=a[j];
            }
        }
        for (int k = 0; k< a.length; k++) {
            if (a[k]%2==0){
                oushu+=1;
            }else {
                jishu+=1;
            }
        }
        System.out.println("最大值为"+max+"最小值为"+mini+"偶数有"+oushu+"个"+"奇数有"+jishu+"个");
    }
}

 

posted @ 2020-04-16 11:46  啪啪怪  阅读(191)  评论(0编辑  收藏  举报