隔壁老伍丶
import java.util.Arrays;
import java.util.Random;
public class MookQue {
public static void main(String[] args) {
int[] arr = getAry(8);
getAverage(arr);
printArr(removeMin(arr));
}
private static int[] getAry(int length)
{
int[] arr = new int[length];
for(int i=0; i<length; i++) {
int number = new Random().nextInt(20) + 1;
while(number%2 != 0)
{
number = new Random().nextInt(20) + 1;
}
arr[i] = number;
}
return arr;
}
private static void getAverage(int[] arr)
{
double sum = 0;
for (int i : arr) {
sum += i;
}
System.out.println(sum/arr.length);
}
private static void printArr(int[] arr)
{
for (int i : arr) {
System.out.print(i + " ");
}
}
private static int[] removeMin(int[] arr)
{
Arrays.sort(arr);
arr[0] = arr[arr.length-1];
return Arrays.copyOf(arr, arr.length-1);
}
}