1.有10个评委打分,(去掉一个最高一个最低)求平均分。

package jxk;

public class Der {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        pj10();
    }
    public static void pj10() {
    int[] array = {98, 96, 98, 94, 98, 91, 88, 72, 94, 99};
    int index = 0, sum = 0, temp = 0, pj = 0 ;
    //找到最低分 冒泡排除,从小到大排列
    for (int i = 0; i < array.length - 1; i++) {
    for (int j = i + 1; j < array.length; j++) {
    if (array[j] < array[i]) { //如果是大于号, 将是从大到小
    temp = array[i];
    array[i] = array[j];
    array[j] = temp;
    }
    }
    }
    //求和
    while (array.length != index) {
    sum += array[index];
    index++;
    }
    do {
    sum = sum - array[0] - array[array.length-1]; //去掉最高分和最低分,
    } while (false);
    pj = sum / 8;
    System.out.println(pj);

    }
}

2.自学一下Java随机数,生成一个长度为10的随机数组(每个数的范围是0~99),排序后输出。

package jxk;
import java.util.*;
public class ftw {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        int[] arr = {45,88,72,32};
          System.out.println(Arrays.toString(arr));
         //  RandomArray();
          sort(arr);
          System.out.println(Arrays.toString(arr));
        }
         private static int[] RandomArray(){
          int n = new Random().nextInt(10); //获取随机n
        //  System.out.println(n);
          int[] arr =new int[10];    //随机长度的数组
          for (int i = 0; i < arr.length; i++) {
           arr[i] = new Random().nextInt(99);//数组元素取值范围
         
          }
          return arr;
         }
         
         private static void sort(int[] a){
          for (int i = 0; i < a.length; i++) {
           for (int j = a.length -1;j>i;j--) {
            if(a[j]>a[j-1]){
             int temp =a[j];
             a[j] = a[i];
             a[i] = temp;
            }
            
           }
           
          }
           }
}

3.制作彩票35选7程序。 (就是1~35随机生成7个不重复的数)

package jxk;
import java.util.*;
public class ftw {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        List<Integer> reList = new ArrayList<Integer>();
        int[] num = new int[35];// 创建一个35长度的int数组
        boolean[] flag = new boolean[35];
        int count = 0;
        for (int i = 0; i < 35; i++)
        {
        num[i] = i + 1;
        flag[i] = true;
        }
        // 判断抓取到的数字够不够7个,不够的话,继续抓取
        while (count != 7) {
        int k = (int) (Math.random() * 35);
        if (flag[k]) {
        reList.add(num[k]);
        flag[k] = false;
        count++;
        }
        }
        // 抓取结束后输出抓取结果
        Object[] result = reList.toArray();
        System.out.print("[\t");
        for (int i = 0; i < result.length; i++) {
        System.out.print(result[i] + "\t");
        }
        System.out.print("]");
}
}

4.定义一个长度为10的int数组,统计数组中的最大值、最小值、以及奇数和偶数的个数

package jxk;
import java.util.*;
public class ftw {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        int arr[]= {23,6,87,37,52,98,66,54,99,22};
        int arrMax=arr[0];
        int arrMin=arr[0];
        int arrCountQ=0; //记录奇数个数
        int arrCountO=0; //记录偶数个数
        for(int i=0;i<arr.length;i++) {
                //判断最大值
        if(arr[i]>arrMax) {
        arrMax=arr[i];
  }
          //判断最小值
        if(arr[i]<arrMin) {
        arrMin=arr[i];
   }

        if(arr[i]%2==0) {
        arrCountO +=1; //判断偶数个数
        }else {
        arrCountQ +=1; //判断奇数个数
      }
}
         System.out.println("数组的最大值为:"+arrMax);
        System.out.println("数组的最小值为:"+arrMin);
        System.out.println("数组的偶数个数为:"+arrCountO);
        System.out.println("数组的奇数个数为:"+arrCountQ);

            }

 }