CCF 201903-1 小中大

#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#define mem(a,b) memset(a,b,sizeof(a));
using namespace std;
typedef long long ll;
const int maxn = 500005;
const ll INF = 0x3f3f3f3f;

int main()
{
    int n;
    int a[100005];
    scanf("%d",&n);
    for(int i = 1; i <= n; i++) {
            scanf("%d",&a[i]);
    }
    sort(a+1,a+1+n);
    int mmin = a[1], maxn = a[n];
    double mid;
    if(n % 2 == 0) {
         mid = (a[n/2+1]+a[n/2])*1.0/2;
    }
    else {
        mid = a[n/2+1];
    }
    if(mid == (int)mid) printf("%d %.0lf %d\n",maxn,mid,mmin);
    else printf("%d %.1lf %d\n",maxn,mid,mmin);
    return 0;
}

注意输出格式

上一篇:Scala_05_方法和函数


下一篇:java接口interface与scala特质trait区别;java中接口与抽象类abstract class区别;scala中特质与抽象类区别...