© 2015-2019 Wang Liguang. All Rights Reserved. This article is a blogger original article, shall not be reproduced without the bloggers allowed in any form, otherwise it will pursue your legal responsibility. You are reading this article means that you have agreed to the Site statement (see top article)! This article is for reference only, please effectiveness of screening yourself, any problems, bloggers do not assume any responsibility!
#include <bits/stdc++.h>
using namespace std;
#define MAX 100001
int a[MAX];
int main(){
int n, i = 0, max = 0, min = 0, middle = 0, flag = 0;
double middle1 = 0;
memset(a, 0, sizeof(a));
cin >> n;
for(i=0; i<n; i++){
cin >> a[i];
}
if(a[0] >= a[1]){
max = a[0];
min = a[n-1];
}
else if(a[0] <= a[1]){
max = a[n-1];
min = a[0];
}
if(n % 2 == 0){
if((a[n/2]%2 == 0 && a[n/2-1]%2) || (a[n/2]%2 && a[n/2-1]%2 == 0)){
middle1 = (a[n/2] + a[n/2-1])/2.0;
flag = 1;
}
else{
middle = (a[n/2] + a[n/2-1])/2.0;
}
}
else if(n % 2){
middle = a[n/2];
}
cout << max << " ";
if(flag){
cout << setiosflags(ios::fixed) << setprecision(1) << middle1 << " " ;
}
else{
cout << middle << " " ;
}
cout << min;
return 0;
}