[AppleScript] 纯文本查看 复制代码 public static void main(String[] args) {
ArrayList<Integer> list = new ArrayList<>();
Random r = new Random();
for(int i=0; i<8; i++){
int num = r.nextInt(19)+2;
if(num%2 == 0){
list.add(num);
}else{
i--;
}
}
System.out.println(list);
int sum = 0;
for(int i=0; i<list.size(); i++){
sum += list.get(i);
}
System.out.println("平均值:"+sum/list.size());
for(int i=0; i<list.size(); i++){
if(list.get(i) < sum/list.size()){
list.remove(i);
i--;
}
}
System.out.println(list);
}
|