西电复试之——CCF201903-01 小中大
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn = 101000;
int a[maxn] = { 0 };
int main() {
int n;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a[i];
}
sort(a, a + n);
cout << a[n - 1] << " ";
if (n % 2 == 0) {
if ((a[n / 2 - 1] + a[n / 2]) % 2 == 1) {
printf("%.1lf ", (double)((a[n / 2 - 1] + a[n / 2]) / 2.0));
}
else
{
cout << (a[n / 2 - 1] + a[n / 2]) / 2 << " ";
}
}
else
{
cout << a[n / 2] << " ";
}
cout << a[0];
return 0;
}
双精度和小数点问题
double双精度 输出%.1lf