除数的话要用double保存 题目要看清楚 每一个字都要看仔细

import java.util.Arrays;
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < n; i++)
            arr[i] = sc.nextInt();
        Arrays.sort(arr);
        if (arr.length % 2 == 0) {
            String temp = "";
            if ((arr[arr.length / 2 - 1] + arr[arr.length / 2]) / 2* 2 != (arr[arr.length / 2 - 1] + arr[arr.length / 2])) {
                double d1 = (arr[arr.length / 2 - 1] + arr[arr.length / 2]) * 1.0 / 2;
                temp = String.format("%.1f", d1);
            } else
                temp = (arr[arr.length / 2 - 1] + arr[arr.length / 2]) / 2 + "";
            System.out.println(arr[arr.length - 1] + " " + temp + " " + arr[0]);
        } else {
            int d2 = arr[arr.length / 2] ;
            System.out.println(arr[arr.length - 1] + " " + d2 + " " + arr[0]);
        }
    }
}