小中大
问题描述
试题编号: 201903-1
试题名称: 小中大
时间限制: 1.0s
内存限制: 512.0MB
Java满分代码
Java代码
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();
if(arr[0] < arr[n-1]){ int temp = arr[0]; arr[0] = arr[n-1]; arr[n-1] = temp;}
if(n % 2 == 0){
int i = arr[n/2] + arr[n/2-1];
if(i % 2 == 1)
System.out.println(arr[0] + " " + i/2.0 + " " + arr[n-1]);
else
System.out.println(arr[0] + " " + i/2 + " " + arr[n-1]);
} else
System.out.println(arr[0] + " " + arr[n/2] + " " + arr[n-1]);
}
}