题目链接:
计算机软件能力认证考试系统http://118.190.20.162/view.page?gpid=T89
【分析】主要学一下java的四舍五入,String,format("%.f", double);
import java.util.Arrays;
import java.util.Scanner;public class Main {public static void main(String[] args) {Scanner scanner = new Scanner(System.in);int i;int n = scanner.nextInt();int[] arrs = new int[n];double[] ans = new double[3];for(i = 0; i < n; i++){arrs[i] = scanner.nextInt();}ans[0] = arrs[0]; ans[1] = arrs[n - 1];int m = n / 2;if(n % 2 == 0) ans[2] = ((double) arrs[m] + arrs[m - 1]) / 2;else ans[2] = arrs[m];Arrays.sort(ans);for(i = 2; i >= 0; i--){if((int)ans[i] == ans[i]) System.out.print((int)ans[i]);else System.out.print(String.format("%.1f", ans[i]));if(i != 0) System.out.print(" ");}System.out.println();}}