现有3名选手排序输出所有选手的成绩怎么加???
public static void main(String[] args) {Scanner sc = new Scanner(System.in);
System.out.println("----------------------------------------");
System.out.println("* 宏图软件教育演讲与口才比赛评分系统 *");
System.out.println("----------------------------------------");
int[] arr = new int[8];
for (int i =0; i < arr.length; i++) {
System.out.println("-------请输入第" + (i + 1) + "位裁判的打分:");
arr[i] = sc.nextInt( );
}
for (int i = 1; i < arr.length; i++) {
for (int j = 0; j < arr.length - i; j++) {
if (arr[j] > arr[j + 1]) {
int temp = arr[j];
arr[j] = arr[j + 1];
arr[j + 1] = temp;
}
}
}
for (int i = 0; i < arr.length; i++) {
System.out.print(arr[i] + " ");
}
int sum = 0;
for (int i = 1; i < arr.length - 1; i++) {
sum += arr[i];
}
System.out.println("所有平均分数:" + (sum / 8));
}
[此贴子已经被作者于2022-3-31 19:51编辑过]