Loading

java评委打分

package com.lu;

import java.util.Scanner;

public class Text3 {
    public static void main(String[] args) {
        judgesScore();
    }
    public static void judgesScore(){//评委打分
        Scanner input = new Scanner(System.in);
        System.out.println("请输入几名评委打分?");
        int i = input.nextInt();
        double[] arr = new double[i];

        for (int j = 0; j < i; j++) {
            System.out.println("请输入第"+(j+1)+"位评委的打分:");
            arr[j]= input.nextDouble();
        }
        sort(arr);
        double count =0;
        for (int i1 = 1; i1 < arr.length-1; i1++) {
            count+=arr[i1];
            System.out.println(arr[i1]);
        }
        System.out.println("平均分是:"+count/ (arr.length-2));
    }
    public static  double[] sort(double[] sort){//对整数数组进行排序
        double b ;
        for (int i = 0; i < sort.length; i++) {
            for (int i1 = 0; i1 < sort.length; i1++) {
                if (sort[i]<sort[i1]){
                    b=sort[i];
                    sort[i]=sort[i1];
                    sort[i1]=b;
                }
            }
        }
        return sort;
    }
}

posted @ 2024-06-02 15:37  LL。。。  阅读(21)  评论(0)    收藏  举报  来源