急急急!求Java大神帮忙解决这道题!!谢谢啦谢谢啦!
1个回答
展开全部
public static void main(String[] args) {
List<Integer> list = new ArrayList<Integer>();
Random random = new Random();
for(int i = 0 ; i < 6; i++){
list.add((random.nextInt(10)+1));
}
Collections.sort(list);
Collections.reverse(list);
System.out.println("discarded low score :" + list.get(list.size()-1));
System.out.println("discarded high score:" + list.get(0));
int score = 0;
for(int i = 1 ; i < list.size()-1;i++){
score += list.get(i);
}
System.out.println("Total score :" + score/4);
}
List<Integer> list = new ArrayList<Integer>();
Random random = new Random();
for(int i = 0 ; i < 6; i++){
list.add((random.nextInt(10)+1));
}
Collections.sort(list);
Collections.reverse(list);
System.out.println("discarded low score :" + list.get(list.size()-1));
System.out.println("discarded high score:" + list.get(0));
int score = 0;
for(int i = 1 ; i < list.size()-1;i++){
score += list.get(i);
}
System.out.println("Total score :" + score/4);
}
更多追问追答
追问
谢谢谢谢!不过只有这么短?
追答
恩 满足问题的要求了呀 也可以写的麻烦些
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询